Skip to content

Instantly share code, notes, and snippets.

@martin308
Last active September 3, 2015 17:05
Show Gist options
  • Save martin308/d2c36fcc6b9481384a35 to your computer and use it in GitHub Desktop.
Save martin308/d2c36fcc6b9481384a35 to your computer and use it in GitHub Desktop.
Bugsnag Sample
using Bugsnag.Clients;
using System;
using System.Web.Mvc;
namespace MyAwesomeWebApp
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public sealed class BugsnagExceptionHandler : HandleErrorAttribute
{
internal BugsnagExceptionHandler()
{
}
public override void OnException(ExceptionContext filterContext)
{
if (filterContext == null || filterContext.Exception == null)
return;
if (Bugsnag.Clients.WebMVCClient.Config.AutoNotify)
WebMVCClient.Notify(filterContext.Exception);
}
}
}
using System;
using System.Web.Mvc;
namespace MyAwesomeApp
{
public class Global : System.Web.HttpApplication
{
private void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new BugsnagExceptionHandler());
}
protected void Application_Start(object sender, EventArgs e)
{
RegisterGlobalFilters(GlobalFilters.Filters);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment