Exception Handling application block error number

Topics: Exception Handling Application Block
Mar 18, 2011 at 12:26 AM



When using the exception handling application block how can we give custom error number.For each exception caught.




Mar 18, 2011 at 6:14 AM


Before passing the actual error to the HandleException method, you can modify the actual exception by adding to the Data property of the exception:

                // some codes           

            catch (Exception originalException)
                Exception exception;
                originalException.Data.Add("Error Number", 19);
                ex.HandleException(originalException, "MyPolicy", out exception);


The data will appear to the ExtendedProperties when you log the exception through Logging Exception Handler.