Customizing the Exception Reporter

The ExceptionReporter constructor can accept an instance of IExceptionWindowBehavior to permit customizing the exception window.

You can either create a class that implements this interface or extend from class DefaultExceptionWindowBehavior and overload as needed.

static ExceptionReporter _reporter = new ExceptionReporter(new CustomExceptionWindowBehavior());
internal static ExceptionReporter Reporter
{
    get { return _reporter; }
}

...

[Serializable()]
public class CustomExceptionWindowBehavior : DefaultExceptionWindowBehavior
{
    public override string Title
    {
        get
        {
            return "Exception Viewer";
        }
    }

    public override ExceptionWindowStyle Style
    {
        get
        {
            return ExceptionWindowStyle.ShowReportButton;
        }
    }

    public override string OnComposeDetailedDescription(Exception e)
    {
        return "An unexpected error occurred:" + Environment.NewLine +
                Environment.NewLine +
                base.OnComposeDetailedDescription(e);
    }

    public override void OnException(Exception e, out bool displayExceptionWindow)
    {
        displayExceptionWindow = true;
    }

    public override void OnReportException(Exception e)
    {
        MessageBox.Show("Report button was pressed.");
    }
}

Last edited Oct 4, 2012 at 11:05 PM by jah4, version 2

Comments

No comments yet.