I need to handle all the errors in one class (in fact - not all, but it does not matter).
Processing should occur so that the handler itself redirects the error to the desired class:
try { //Ошибка } catch (Exception e) { handleError(e); //Передается в нужный класс (обработчик) } I found two solutions:
Call the static class method
ErrorHandler.handle(e).Import the same static class method with a static import and call
handle(e)immediately.
Only in both cases there is a direct link to the class, which is undesirable.
Is there any way to centrally handle errors so that one class receives them? I wanted to consider the option with the logger, but did not find such a logger to get errors in a certain class.