Skip to content

Instantly share code, notes, and snippets.

@niemyjski
Last active December 15, 2020 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niemyjski/edb0fdf902aa1034c152f0d6e6e98489 to your computer and use it in GitHub Desktop.
Save niemyjski/edb0fdf902aa1034c152f0d6e6e98489 to your computer and use it in GitHub Desktop.
Exceptionless Ignore Third Party Exceptions
// 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