c# - Exception Handling Application Block - how to replace original message with my own based on some properties of the original message? -
i'm creating class library uses aggregated (built-in) com object. methods , properties of com-object may throws comexception, errorcode property hresult indicates errors in com-object's internal logic.
for example, hresult (and, therefore, comexception.errorcode) = -1001 means input parameter of particular method has bad format.
i want utilize exception handling application block in library , replace comexceptions meaningful errorcode custom exceptions in next manner:
comexception.errorcode = -1001 ---> mylibraryexception.errorreason = deviceerror.badformatofinputparam && mylibraryexception.innerexception = originalcomexception, deviceerror enum & definite deviceerror memeber each particular hresult com-object.
how can achieve using exception handling application block?
thanks
you need write custom exception handler , plug block.
you don't version of entlib you're using. if it's version 5.0 or later, grab enterprise library extensibility hands-on labs. first exercise in on how write custom exception handler.
from there you'll need implement logic whatever want.
Comments
Post a Comment