Is there a way to catch all the unhandled exceptions thrown by this class?

I know how to catch all the unhandled exceptions in a given thread, but I wonder if there is a way to catch all the unhandled exceptions set by this class instead of wrapping each of the calls in a catch try block.

If there is no way to do this (probably it will), how would you achieve the same effect?

To give a little context, I use a custom proxy code that separates the rest of the application from the service data contract (WCF). I basically need to catch errors so that I can extract certain fields (internal descriptions, etc.), Pack them in a custom exception, and throw it again.

Any help was appreciated.

+3
source share
6 answers

When it comes to WCF exceptions, I would recommend connecting special behavior to the WCF pipeline. I wrote a detailed example here

It is based on two interfaces IErrorHandler and IServiceBehavior, it can also be used as an attribute in file configurations.

+7
source

No, exception handling is closely related to threads, as threads execute code classes.

In addition, there is no reason to transfer all calls to try / catch. Not knowing your code, this is most likely not entirely correct. Exception handling frees you from handling each error locally. Hug this and your code will be much simpler.

+3
source

@Brians:

- (wcf),

. , ( , ). , (, FileNotFoundException, SQL ..), Rethrow .

,

( , , , ), .

IErrorHandler (MSDN doco ).

+2

, , .

, , -, . - catch try .

0

, Enterprise Library PostSharp. , , ( ) , , . , , , (). , .

The corporate library and similar tools make wrappers, as EFrank suggested, but they generate them automatically, and these wrappers are transparent, so you just call the methods of your class, and you don’t even know that you are working with a proxy.

And the Enterprise Library has WCF support, as I think it should be your choice

0
source

Try ELMAH, it will handle any unhandled exception https://code.google.com/p/elmah/

-1
source

Source: https://habr.com/ru/post/1763761/


All Articles