I heard that it is possible, after throwing an Exception
process it in catch
, and to return to the point of origin of Exception
itself to continue.
It should look something like this:
try { // Вызываем исключение // Возвращаемся сюда для продолжения исполнения кода } catch (SomeEx) { // Обработка исключения и возврат обратно в вышестоящий блок try{} }
The question is : is there really such a way?
It is necessary approximately in such a situation: there is a deeply buried code that opens a connection to the database. Below is the code for loading data from the database. So, I want to make a check on the correctness of the database (base version) at the connection opening level: if the version is incorrect, you need to give the user a message that the version is old, but you can continue executing the code to load data from it (this message is not critical).
I also thought about the post-inspection, but the fact is that the connection is opened in various places, and the post-inspection version will also have to be spread all over the code, which is not good.