|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Enterprise Library: pass arguments to WrapHandler & ReplaceHandler?I'm retrofitting some code to use the EHAB from the EL. The standard way of writing EL Exception code is as follows: try { // run code } catch(Exception ex){ bool rethrow = ExceptionPolicy.HandleException(ex, "Wrap Policy"); if (rethrow) throw; } The problem is that wrapping an exception (or replacing it) doesn't do a whole lot of good if I can't set some properties on the wrapping/replacing exception--or at least pass some arguments to the constructor. Of course I can set a default message for the exception via configuration, but that's nearly useless in a real application (perhaps "radically insufficient" would be better than "useless," but you get the drift). I need to attach dynamic, runtime info to the new exception, but would like to know if I can do it without coding things the usual way, i.e. try { // run code } catch(Exception ex) { // doing things the old way UsefulException uex = new UsefulException( "SomeMessage", ex ); uex.SomeAdditionalInfo.Add( "CompanyID", _executingCompanyID ); uex.SomeAdditionalInfo.Add( "ProcessingGuid", currentGuid ); bool rethrow = ExceptionPolicy.HandleException( uex, "LogAndReportPolicy"); if (rethrow) throw; } Many thanks in advance ---the PseudoLatino P.S. Can anyone give me a good example of where/how/why you're using the Replace/WrapHandlers? |
|||||||||||||||||||||||