Discussion:
ExceptionManager and publishing custom exceptions
Darryl Luther
2007-11-15 18:19:00 UTC
Permalink
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="***@exceptions.com"
mailfromname="Intranet Maintenance Exception"
mailto="***@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="***@exceptions.com"
mailfromname="Intranet Maintenance Warning"
mailto="***@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
"***@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!

Darryl Luther

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

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