Skip to content

Instantly share code, notes, and snippets.

@azcoov
Forked from martin308/BugsnagExceptionHandler.cs
Last active September 3, 2015 17:05
Show Gist options
  • Save azcoov/c82c61ff3a66ad375ecc to your computer and use it in GitHub Desktop.
Save azcoov/c82c61ff3a66ad375ecc 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