简体   繁体   中英

3rd party library catches my exceptions

I've got a 3rd party API library which contains a set of request functions. Responses are got by subscribing to events.

If and exception is thrown in my event handler - the 3rd party library catches it and does nothing after. This doesn't let me know if I have any problems with my code.

Is there any way to catch my exceptions before the 3rd party library does?

I thought on writing wrappers for event handlers but it doesn't seem to be a good solution.

Subscribing to AppDomain.FirstChanceException doesn't give any effect.

Is there any way to catch my exceptions before the 3rd party library does?

HandlerFunction()
{
    try
    {
        /* place handler body here */
    }
    catch(Exception e)
    {
        /* you may store/log the exception object here */
    }
}
ThirdPartyObject.Event += HandlerFunction;

In the catch clause, you may also add your exception object to a global error log so that you can keep track of it.

Also you may place a breakpoint in the exception clause to debug your errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM