-
-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement ignoredErrors instead of ignoredExceptions, matching on sev…
…eral possible messages as in the JS SDK and not on only on the Exception class
- Loading branch information
Showing
12 changed files
with
170 additions
and
112 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.sentry.util; | ||
|
||
import io.sentry.FilterString; | ||
import io.sentry.SentryEvent; | ||
import io.sentry.protocol.Message; | ||
import io.sentry.protocol.SentryException; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public final class ErrorUtils { | ||
|
||
/** Checks if an error has been ignored. */ | ||
@ApiStatus.Internal | ||
public static boolean isIgnored( | ||
final @Nullable List<FilterString> ignoredErrors, final @NotNull SentryEvent event) { | ||
if (event == null || ignoredErrors == null || ignoredErrors.isEmpty()) { | ||
return false; | ||
} | ||
|
||
final @NotNull Set<String> possibleMessages = new HashSet<>(); | ||
|
||
final @Nullable Message eventMessage = event.getMessage(); | ||
if (eventMessage != null) { | ||
final @Nullable String stringMessage = eventMessage.getMessage(); | ||
if (stringMessage != null) { | ||
possibleMessages.add(stringMessage); | ||
} | ||
final @Nullable String formattedMessage = eventMessage.getFormatted(); | ||
if (formattedMessage != null) { | ||
possibleMessages.add(formattedMessage); | ||
} | ||
} | ||
final @Nullable List<SentryException> exceptions = event.getExceptions(); | ||
if (exceptions != null && !exceptions.isEmpty()) { | ||
for (final @Nullable SentryException exception : exceptions) { | ||
if (exception != null) { | ||
final @Nullable String value = exception.getValue(); | ||
if (value != null) { | ||
possibleMessages.add(value); | ||
} | ||
} | ||
} | ||
} | ||
final @Nullable Throwable throwable = event.getThrowable(); | ||
if (throwable != null) { | ||
possibleMessages.add(throwable.toString()); | ||
} | ||
|
||
for (final @NotNull FilterString filter : ignoredErrors) { | ||
if (possibleMessages.contains(filter.getFilterString())) { | ||
return true; | ||
} | ||
} | ||
|
||
for (final @NotNull FilterString filter : ignoredErrors) { | ||
for (final @NotNull String message : possibleMessages) { | ||
if (filter.matches(message)) { | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
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
Oops, something went wrong.