bugsnag / bugsnag-java

BugSnag error reporting for Java.
https://www.bugsnag.com/platforms/java/
MIT License
56 stars 34 forks source link

Filter unhandled exceptions by package #201

Closed carlodrift closed 1 year ago

carlodrift commented 1 year ago

Hi, I use Bugsnag on my public Minecraft plugin. However, a Minecraft plugin can run several Java plugins, so I get unhandled exceptions from all the plugins. Is there any way in the code or dashboard to filter unhandled exceptions by package name or any other solution to avoid this problem? Thanks.

carlodrift commented 1 year ago

I've tried this, but I don't know if it's the right thing to do:

        bugsnag.addCallback(report -> {
            StackTraceElement[] trace = report.getException().getStackTrace();
            boolean reportError = false;
            for (StackTraceElement element : trace) {
                if (element.getClassName().startsWith("net.clementraynaud")) {
                    reportError = true;
                    break;
                }
            }
            if (!reportError) {
                report.cancel();
            }
        });