Description
I just integrated Bugsnag into a Dropwizard application. In this application I have a mechanism in place to catch unhandled exceptions, log them, delegate to my own ErrorReporter
interface, and then return an appropriate JSON response (e.g., 500 ISE).
I integrated Bugsnag by creating a BugsnagErrorReporter
and suppressing the automatic uncaught exception handler. This is working great, but as my implementation calls bugsnag.notify()
it reports all exceptions as handled. I would like to be able to report these as unhandled exceptions since they're being caught by a JAX-RS ExceptionMapper
rather than in a catch block somewhere. There are other cases where I would want to report handled exceptions (i.e., places where I can gracefully recover but still want to know of a problem). This is similar in concept to how the Spring module is specifying a SeverityReasonType
of REASON_UNHANDLED_EXCEPTION_MIDDLEWARE
in its various handlers.
Looking at Report
, the getUnhandled()
method drives this setting in the JSON sent to Bugsnag and that method keys off of the HandledState
.
Implementation Options:
-
Alter the
bugsnag.notify()
methods. There are a number of overloads and I am hesitant to disrupt this since it's the primary API a user would interact with. -
Alter the
Report
class to provide a way to flag the report as unhandled. e.g.,report.flagAsUnhandled()
,report.flagAsUnhandledFromMiddleware()
, or etc. This would change the underlyingHandledState
. -
Place my
BugsnagErrorReporter
in thecom.bugsnag
package in my own code so that I can access package-private functionality. This would solve my immediate problem but would require me to use a non-public API that could change later and doesn't help anyone else who may want to report unhandled exceptions themselves.
I would be happy to create a PR that implements this, but I wanted to check with you first to see if this is something you agree with and/or if you have a preferred approach.