Skip to content

Instantly share code, notes, and snippets.

@niemyjski
Created December 3, 2019 13:57
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/f9439524658c0c077a66f1d9170ce15a to your computer and use it in GitHub Desktop.
Save niemyjski/f9439524658c0c077a66f1d9170ce15a to your computer and use it in GitHub Desktop.
Exceptionless.Net Cancel Error By Message And Type
[Priority(21)]
public class CancelErrorByMessageAndType : IEventPlugin {
public void Run(EventPluginContext context) {
// Only check error events.
if (context.Event.Type != Event.KnownTypes.Error)
return;
var error = context.Event.GetError();
if (error == null)
return;
if (!error.Message?.Contains("my error message"))
return;
if (!String.Equals(error.Type, "System.Exception")
return;
// You can also iterate over the error.StackTrace collection and check method name too.
context.Cancel = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment