P
P
Pavel2020-11-01 18:38:49
C++ / C#
Pavel, 2020-11-01 18:38:49

How to track Exception in all methods?

There is a device that returns an error, after which it needs to be reinitialized, an error can occur in different methods, but the error id is the same. How can the exception be handled globally, so as not to be written in catch in each method?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ananiev, 2020-11-01
@SaNNy32

https://docs.microsoft.com/ru-ru/dotnet/api/system...

V
Vladimir Korotenko, 2020-11-01
@firedragon

I would suggest something like TryGet pattern
https://stackoverflow.com/questions/37546622/best-...
Another option is a global catch that catches not only the exception, but also through reflection the method that was called.
Well, or a wrapper that takes a lambda and repeats it several times with exceptions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question