Search code examples
c#error-handlingerror-logging

Does the filter context contain Source Error or Source File?


I have created a custom error handler and I wish to log the source file and the source error, but none of my research tells me if this is possible.

Does anyone know if the filterContext will give this to me or if there is another way to get the information I wish?

Thank you for any help.


Solution

  • In my experience it is not possible but you should get all the information you need by logging the stack trace.

    Try:

    public override void OnException(ExceptionContext filterContext)
    {
        ErrorLog errorLog = new ErrorLog();
        errorLog.ExeptionStackTrace = filterContext.Exception.StackTrace;
    }