Customizing error reports

In order to quickly reproduce and fix errors, it is often helpful to send additional application-specific diagnostic data to Bugsnag.

The Report object is available in beforeNotify() callbacks and can be accessed or modified using the following methods.

The Report methods support chaining, for example:

report.setSeverity(Severity.ERROR).setContext("Processing");

Bugsnag will automatically add diagnostic information on the JVM runtime, O/S, and locale. For javax.servlet API apps information about the request will be collected.

addToTab

Sets a piece of information to be displayed on the error in Bugsnag. The first argument is the tab name, the second argument is the key for the data, and the third argument is used as the value. Also see clearTab.

report.addToTab("system resources", "memory", "10MB");

cancel

Prevents the report from being sent to Bugsnag.

report.cancel();

clearTab

Clears a tab of information so it will not be sent to Bugsnag. Also see addToTab.

report.clearTab("system resources");

getException

Returns the thrown Throwable that is being reported.

getExceptionName

Returns the full name of the Throwable that is being reported.

getStackTrace

Returns the Throwable’s array of StackTraceElements.

setAppInfo

Set information about the application the error occurred on, to appear on the app tab.

report.setAppInfo("Module", "parser");

setContext

Set the context of the error. Defaults to the class the error occurred in.

report.setContext("Processing");

setDeviceInfo

Set information about the device the error occurred on, to appear on the device tab.

report.setDeviceInfo("Cluster number", "2");

setGroupingHash

Sets the groupingHash used by Bugsnag to manually override the default grouping technique. This is an advanced option, and should be used with care.

Any errors that are sent to Bugsnag that have the same groupingHash will be grouped as one. As the name implies, this option accepts a hash of sorts.

// ... generate the hash
String groupingHash = "f8803769f3e293dfcabdb6dec5100b8c52c6ae6b";
report.setGroupingHash(groupingHash);

setUser

Set information about the user the error occurred for. Details can also be set individually, see setUserId, setUserEmail and setUserName.

report.setUser("12345", "user@example.com", "User Name");

setUserEmail

Set the email address of the user the error occurred for. Also see setUser.

report.setUserEmail("user@example.com");

setUserId

Set an identifier for the user the error occurred for. Also see setUser.

report.setUserId("12345");

setUserName

Set the name of the user the error occurred for. Also see setUser.

report.setUserEmail("User Name");

setSeverity

Overrides the severity of the error. Valid severities are ERROR, WARNING and INFO.

report.setSeverity(Severity.WARNING);