Forked from martin308/BugsnagExceptionHandler.cs
Last active
September 3, 2015 17:05
-
-
Save azcoov/c82c61ff3a66ad375ecc to your computer and use it in GitHub Desktop.
Bugsnag Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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