I am logging error with Elmah inside a try-catch block. here is the code;
try {
DateTime.Parse("poo");
} catch (Exception err) {
Elmah.ErrorSignal.FromCurrentContext().Raise(err);
}
I would like to log some specific info like some information which can be retrieved from previous methods or properties on the same context but the Exception properties are readonly. what is the best way to do that?
My main goal is to be able to do something like below;
} catch (Exception err) {
err.Message += "poo";
Elmah.ErrorSignal.FromCurrentContext().Raise(err);
}
You could create your own exception object and pass that to Elmah.
Setup a static helper method and do something like
public static void HandleError(Exception ex, String customMsg)
{
Exception newEx = new Exception(customMsg, ex);
Elmah.ErrorSignal.FromCurrentContext().Raise(newEx);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With