Last active
December 15, 2020 21:45
-
-
Save niemyjski/edb0fdf902aa1034c152f0d6e6e98489 to your computer and use it in GitHub Desktop.
Exceptionless Ignore Third Party Exceptions
This file contains hidden or 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
// Create our own client instance so we aren't conflicting if anyone else is using exceptionless in an addon. | |
private readonly ExceptionlessClient _client = new ExceptionlessClient(); | |
_client.Configuration.AddPlugin<IgnoreLicensingAndNonGeneratorExceptionsPlugin>(); | |
[Priority(30)] | |
private class IgnoreLicensingAndNonGeneratorExceptionsPlugin : IEventPlugin { | |
private static readonly List<string> _handledNamespaces = new List<string> { | |
"MyNamespace", | |
"MyThirdPartyDependencyNamespace" | |
}; | |
public void Run(EventPluginContext ctx) { | |
if (!ctx.ContextData.IsUnhandledError || !ctx.Event.IsError() || !ctx.ContextData.HasException()) | |
return; | |
var exception = ctx.ContextData.GetException(); | |
if (exception == null) | |
return; | |
var error = ctx.Event.GetError(); | |
if (error == null) | |
return; | |
//Ignore any unhandled exceptions that were not thrown by our code. | |
if (!error.StackTrace.Select(s => s.DeclaringNamespace).Distinct().Any(ns => _handledNamespaces.Any(ns.Contains))) | |
ctx.Cancel = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment