Created
December 3, 2019 13:57
-
-
Save niemyjski/f9439524658c0c077a66f1d9170ce15a to your computer and use it in GitHub Desktop.
Exceptionless.Net Cancel Error By Message And Type
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
[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