I will describe how my application is currently set up and then explain the problem I am faced with.
In my application all i want to do is log an error when it happens. I don't want to rethrow or anything like that. In my application i want to store different information in the exception depending on what exception was thrown. For example if its a socket
exception i add the socket exception error code to the Data collection of the exception object and if there is a problem with the input data to the application i store the input data in the data collection.
So my application has try/catch finally statements that look like this
//get socket error code and add to e
//get input data for application and add to e
Being as i want the same outcome for each application type in the exception handling application block i created one exception policy called LoggingPolicy with one Exception type added for Exception which has a Category called General with one TraceListener
associated with it. This set up logs the messages for all exceptions that are generated without me having to add multiple exceptions to the exception policy. I think this is ok? If i could do this better I would welcome advice.
I now have the problem that i need to raise an email if a specific socket error occurs. However with winsock errors you don't get different socket exceptions for the different types of error. You get one socket exception with an error code property that
indicates the nature of the error. If i got different socket exceptions for the different types of errors I could just add the relevant socket exception to my existing LOggingPolicy and assign it a logging handler that has a category associated with an
email trace listener. But i can't do this (unless someone can tell me different) so the best I can think of is to have a second exception policy. This one has one SocketException which has a logging handler assigned to a Category called email which is linked
to an email trace listener. Then in the try catch blocks above i would have to evalute the error code of the socket exception like so
catch(socket exception e)
if e.errorCode is not urgent then
I don't think the EHAB was designed to be used like that but i think its the best I can do. What do you think?