ExceptionManager and custom exceptions

Darryl Luther <[email protected]> Thu, 29 Nov 2007 14:04:48 -0800
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <[email protected]>
I posted this on the DOTNET-WEB discussion list, but didn't receive any
replies so I thought I'd try here. My apologies if this is completely OT for
this list...

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="[email protected]"
       mailfromname="Intranet Maintenance Exception"
       mailto="[email protected]"
       mailsubject="Unhandled Intranet Maintenance Exception">
   </publisher>
   <publisher mode="on"
       assembly="IntranetMaintenance"
       type="IntranetMaintenance.ExceptionMailPublisher"
       exclude="*"
       include="IntranetMaintenance.DuplicateFileException"
       mailserver="mail.exceptions.com"
       mailfromaddress="[email protected]"
       mailfromname="Intranet Maintenance Warning"
       mailto="[email protected]"
       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
"[email protected]". 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!

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com