Skip to content

Commit

Permalink
Only send errors that occur within/include our namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jmshal committed Jan 31, 2016
1 parent 4b372fc commit 0368329
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.jacobmarshall.meloooncensor.listener.ChatEventListener;
import io.github.jacobmarshall.meloooncensor.command.CensorCommandExecutor;
import io.github.jacobmarshall.meloooncensor.listener.PlayerJoinEventListener;
import io.github.jacobmarshall.meloooncensor.listener.UnhandledExceptionListener;
import io.github.jacobmarshall.meloooncensor.updater.CheckForUpdatesTask;
import org.bukkit.plugin.java.JavaPlugin;
import org.mcstats.Metrics;
Expand All @@ -21,6 +22,7 @@ protected void startBugsnag () {
bugsnag = new Client("b5347687fe92ee7494d20cdf5a725fad");
bugsnag.setAppVersion(getDescription().getVersion());
bugsnag.setProjectPackages("io.github.jacobmarshall.meloooncensor");
bugsnag.addBeforeNotify(new UnhandledExceptionListener());
}

protected void startMetrics () {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.github.jacobmarshall.meloooncensor.listener;

import com.bugsnag.BeforeNotify;
import com.bugsnag.Error;

public class UnhandledExceptionListener implements BeforeNotify {

@Override
public boolean run (Error error) {
StackTraceElement[] stackTrace = error.getStackTrace();

for (StackTraceElement frame : stackTrace) {
// Only send errors that occur within/include our namespace
if (frame.getClassName().startsWith("io.github.jacobmarshall.meloooncensor")) {
return true;
}
}

return false;
}

}

0 comments on commit 0368329

Please sign in to comment.