Customizing error reports

Add diagnostic data to every error report, conditionally adjust error reports, or indeed, skip notifying Bugsnag of the error.

Adding callbacks

If you’d like to add diagnostic data to every error report, or adjust error reports conditionally, you can add callbacks which will be invoked each time a report will be sent.

In Symfony callbacks should be registered within the boot function of your app/AppKernel.php file:

public function boot()
    $this->container->get('bugsnag')->registerCallback(function ($report) {
        'account' => [
            'name' => 'Acme Co.',
            'paying_customer' => true,

To cancel the error report, return false from the function.

See $report object for methods available within the callback.

The $report object

The following properties and methods are available on the $report object.


Add additional metadata to the error report, or delete existing metadata. Conflicting properties will be merged recursively, favouring the new values. Properties with a value of null will be deleted.

    'account' => [
        'paying' => true,
        'name' => 'Acme Co',
        'contact' => null # Will be deleted


Gets the Stacktrace object attached to the error report. The stacktrace can be filtered or otherwise modified as needed.

This behavior is useful when there is a designated error handling function within application code, and error reports are being grouped by that function on your Bugsnag dashboard. The frames of a stacktrace are ordered such that index 0 is the frame most recently called.

$stacktrace = $report->getStacktrace();
$frames = $stacktrace->getFrames();

if ($frames[0]['method'] == 'log_error') {


Sets the grouping hash of the error report. All errors with the same grouping hash are grouped together. This is an advanced usage of the library and mis-using it will cause your errors not to group properly in your dashboard.

$report->setGroupingHash($report->getName() . $report->getMessage());


Set the error message sent in the error report

$report->setMessage('This was a mistake.');


Set additional metadata to send with this error report, or filter existing metadata.

    'account' => array(
        'paying' => true,
        'name' => 'Acme Co'

You can also pass a 2nd paramater of false stop us merging your metadata, and force us to completely replace it.


Set the error name sent in the error report



Set the severity of the error report. Valid severities are error, warning, and info.

By default, all unhandled exceptions are set to severity error and all handled exceptions are set to severity warning.



You can set the associated user on the error.

    'id' => '123456',
    'name' => 'Leeroy Jenkins',
    'email' => '',