arrow_back How to track Exception in all methods?

2 votes
There is a device that returns an error and then needs to be re-initialized, the error can occur in different methods, but the error id is the same. How can I handle exception globally so I don't have to write it in catch in each method?

1 comment

I would make a wrapper over this device in which exceptions are caught and handled correctly.
Still, logic on exceptions is not very good.
And global exception handling in business logic is even worse.

2 Answers

0 votes
I would suggest something like TryGet pattern

The other option is a global catcher, catching not only the exception, but also through reflection the method that was called.

Or a wrapper that takes a lambda and repeats it several times on exceptions
1 vote