views:

33

answers:

1

Hi,

I'm using the .NET Exception Management Application Block (EMAB).

As part of this I am implementing IExceptionPublisher classes.

However, I am wondering what happens if these publishers encounter an Exception.

I had a bit of a look around and apparently they are meant to do something like this:

try 
{
    /* Normal Exception Publishing */
}
catch
{
    ExceptionManager.PublishInternalException(exception, additionalInfo);
}

Source:

One caveat: what happens if there is an exception in our custom publisher code, preventing the publishing to MSMQ? For that, we turn to the ExceptionManager.PublishInternalException method, which will publish the exception to the default publisher, which is the Windows application event log.

However, PublishInternalException is both protected and internal so I would have to be implementing ExceptionManager, not IExceptionPublisher, to access it.

A: 

It handles itself, publishing both the original Exception and the Exception your IExceptionPublisher threw to the Application Log

The idea to manually call PublishInternalException must have been related to an early beta. The current ExceptionManager wraps the IExceptionPublisher calls in its own try-catch which calls PublishInternalException itself. If you check out the code in Reflector it basically does this:

/* Foreach publisher */
Exception originalException;
try
{
    PublishToCustomPublisher(originalException, additionalInfo, current);
}
catch (Exception publisherException)
{
    /* Both of these calls use the DefaultPublisher which is the Application Log */
    PublishInternalException(publisherException, null);
    PublishToDefaultPublisher(originalException, additionalInfo);
}

You may also want to check out the newer Enterprise Library Exception Handling Application Block

Graphain