.net - Enterprise Library How to Implement a IExceptionHandler? -
I would like to introduce a IExceptionHandler to Antipris Library 4.1. In my special case I want to use it to log fogbugs in the exception but internal details are not what I am asking about it. What do I need - best practice policies - apply it, how to get a config for an app.config or web.config i etc.
I have yet to address:
public class LcpFogbugzExceptionHandler: IExceptionHandler {/// & lt; Summary & gt; Starts a new instance of ///; & Lt; See cref = "LcpFogbugzExceptionHandler" /> class. /// & lt; / Summary & gt; Public LcpFogbugzExceptionHandler () {// & lt; Param name = "ignore" & gt; ignore. & Lt; / Param & gt; // NameValueCollection ignore} /// & lt; Summary & gt; Starts a new instance of ///; & Lt; See cref = "T: LcpFogbugzExceptionHandler" /> class. /// & lt; / Summary & gt; /// & lt; Ultimate name = "ignore" & gt; ignore. & Lt; / Param & gt; Public LcpFogbugzExceptionHandler (NameValueCollection ignore) {} /// & lt; Summary & gt; /// handles exceptions /// & lt; / Summary & gt; /// & lt; Ultimate name = "exception" & gt; exception. & Lt; / Param & gt; /// & lt; Param name = "handlinginstance id" & gt; Handling instance ID & Lt; / Param & gt; /// & lt; Returns & gt; & Lt; / Returns & gt; [Sistmkdaygnostikskkdanlysisksuppressmessge ( "Maikrosoftkgloblaijeshn", "Kl300: Spesifaimessgeboksopshns"), Sistmkdaygnostikskkdanlysisksuppressmessge ( "Maikrosoftkgloblaijeshn", "Kl305: Spesifayiformtprovider" Msajid = "Sistmkknhwartktobulan (System.String) ")] public exception handling Akspeshnshn (exception exception, grid handling Instens Aid) return back exceptions series will be passed on to the next // exception handler exception; }}
I'm not sure what you mean by the best practices - you have code skeleton right just fill it with its implementation can be useful random points:
you can read the configuration settings in the normal way ( ConfigurationManager etc.). Your handler is the same process and thread that ExceptionPolicy.HandleException is being called in the first place.
This is a good idea to make the handler code thread safer, if you have to handle exceptions in many threads (and if you do not do this in the project, then you need to be in the next one ).
If you assign any non-stationary instance data to the handler from the calling code, you can populate the exception of the data , which is through the entire handler series and The calling code will be re-protected. I used this technique to send data to a handler, withdrawn data from a handler, and allows a handler to control the actions of the next one in the chain. If you do this, make sure that all data values are serial jubil.
Comments
Post a Comment