Does Exception Handling Block cater for EventTopicExceptions

Topics: Exception Handling Application Block
Sep 16, 2007 at 2:28 PM
Edited Sep 16, 2007 at 2:35 PM
I'm developing using CAB (SmartClient) at the moment - and am interested in using Enterprise Library's Exception Handling Block.

CAB has a particular problem with Exceptions because the EventTopic/Subscribe system uses its own home-grown exception mechanism.

That is, you need to write your own code to handle EventTopicExceptions, to custom- retrieve the Exceptions property - because it uses a (non-standard, made-up) property called Exceptions to hold a list of InnerExceptions instead of what everyone else uses - the InnerExceptions property.

It would certainly make amends if the Exception Handling Block were to cater for this? Or does it have no idea that there might be rogue classes that use different properties to hold InnerExceptions?

I apologise for not digging in and discovering this for myself, but it would be nice to get some thoughts on this issue as well. Perhaps someone else has wrapped up EventTopicSubscriptions using the Exception Handling Block in some other interesting way...
Sep 17, 2007 at 2:16 PM
Hi,

If you need to retrieve the information for logging purposes, you can write your own ExceptionFormatter and configure it for the LoggingExceptionHandler.

Fernando
Sep 27, 2007 at 2:34 PM
If you use the Smart Client Software Factory it builds you an EventTopicExceptionFormatter class ready to use.

Unfortunately I'm struggling to get it to work - it's something to do with the app.config settings though, rather than the class itself.
Dec 17, 2009 at 7:31 PM

I've now on day two trying to get the EventTopicExceptionFormatter to work with EntLib 4.1

I've been totally unable to use the configuration editor to setup this formatter so I've added it manually by hacking up the XML. I finally thought I had it working and then I get the following error when I try to log and use the formatter:

"The type EventTopicExceptionFormatter does not contain the ConfigurationElementTypeAttribute."

At this point I don't know if I'm barking up the wrong tree by manually adding the formatter to the config file or if the formatter class actually needs to be updated with this attribute.  Either way I'm not confident in moving forward.  I suppose there aren't many people using CAB anylonger, but hopefully there is SOMEONE out there that is using it with EntLib 4.1 and can give me a little help.

This is tough.

Dec 17, 2009 at 7:58 PM

OK, this was due to my manual hacking of the XML - I had added a Formatter entry and pointed to an ExceptionFormatter.  My mistake.

Then the next error was:
"Unable to handle exception: 'LoggingExceptionHandler'."

Ah, come on... anyways, good ol' google to the rescue and I found this thread:
http://channel9.msdn.com/forums/Coffeehouse/475472-Enterprise-Library-41-devs-should-DIAF/

Specifically:
"must expose a public constructor that takes a TextWriter object, an Exception object and a GUID instance as parameters."

 

I then changed the EventTopicExceptionFormatter and added the following constructor:

public EventTopicExceptionFormatter(TextWriter writer,
Exception exception, Guid handlingInstanceId)
: base(writer, exception, handlingInstanceId)
{
}

I hope this helps someone out if they come across the same problems.