Publishing custom exceptions with the EMAB

Topics: Building and extending application blocks, Exception Handling Application Block
Dec 7, 2007 at 6:17 PM
I'm trying to configure exception management in a web app to email different addresses depending on the exception generated. To this end I've created my own exception class that implements ApplicationException. For these custom exceptions I'd like the email to go to a different address than all the other exceptions so I have two publisher nodes in web.config as follows:

<exceptionManagement>
<publisher mode="on"
assembly="IntranetMaintenance"
type="IntranetMaintenance.ExceptionMailPublisher"
exclude="IntranetMaintenance.DuplicateFileException"
mailserver="mail.exceptions.com"
mailfromaddress="noreply@exceptions.com"
mailfromname="Intranet Maintenance Exception"
mailto="general.exceptions@exceptions.com"
mailsubject="Unhandled Intranet Maintenance Exception">
</publisher>
<publisher mode="on"
assembly="IntranetMaintenance"
type="IntranetMaintenance.ExceptionMailPublisher"
exclude="*"
include="IntranetMaintenance.DuplicateFileException"
mailserver="mail.exceptions.com"
mailfromaddress="noreply@exceptions.com"
mailfromname="Intranet Maintenance Warning"
mailto="warning.exceptions@exceptions.com"
mailsubject="Intranet Maintenance Duplicate File Warning">
</publisher>
</exceptionManagement>

"IntranetMaintenance" is the namespace for the web app and "DuplicateFileException" is my exception class implementing ApplicationException. Here's how I create the exception in code:

DuplicateFileException e = new DuplicateFileException("Duplicate file found");
NameValueCollection additionalInfo = new NameValueCollection();
additionalInfo.Add("User", _user);
additionalInfo.Add("Workarea", _workarea);
additionalInfo.Add("File", f.Name);
additionalInfo.Add("Exception Type", e.GetType().ToString());
ExceptionManager.Publish(e, additionalInfo);

I added the Exception Type just to make sure that I was indeed specifying the right type to exclude/include in my publisher nodes. The problem is that this exception is still emailed to "general.exceptions@exceptions.com". Clearly I am doing something wrong, but I cannot see what it is. I think I have everything configured properly for what I'm trying to do. Does anyone have any ideas or suggestions? Thanks!
Dec 10, 2007 at 9:33 PM
Hi,

This question is related to the stand alone EMAB, which is quite different from the block that is part of the Enterprise Library. You may find an answer here, but it's really not the best place to post your question.

Regards,
Fernando
Dec 12, 2007 at 8:43 PM
Thanks for the reply. I'm running out of options on where to look for help on this. It seems as though no one has ever wanted to use different publishing methods for custom error types. Hard to believe I'm breaking new ground here, but there you go. I will continue my search elsewhere I guess.