Friday, July 9, 2010

How To: Customize Unhandled Exception Reports in CodeSmith Insight

One of the top benefits of integrating CodeSmith Insight into your application is that it will automatically catch and report all unhandled exceptions. As quick and easy as it is to just let Insight do all the work, you may want to make customizations to these unhandled exception reports. This is very easy to do: Just register for the UnhandledExceptionReporting event in your application startup, and then you can use an event handler to programmatically customize your reports.

Example

protected void Application_Start(object sender, EventArgs e)
{
    InsightManager.Current.UnhandledExceptionReporting += OnUnhandledExceptionReporting;
}

void OnUnhandledExceptionReporting(object sender, UnhandledExceptionReportingEventArgs e)
{
    // You can get access to the report here...
    var report = e.CaseReport;

    // ...and make any updates you wish!
    report.Tags.Add("Unhandled");
}

Real Time Web Analytics