arsen.gandjuns
arsen.gandjuns

Reputation: 15

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.

Upvotes: 0

Views: 137

Answers (1)

Ian CT
Ian CT

Reputation: 1411

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.

Upvotes: 1

Related Questions