Skip to content

Reporting errors

Honeybadger reports uncaught exceptions automatically. In all other cases, use $honeybadger->notify() and $honeybadger->customNotification() to send errors to Honeybadger.

By default, honeybadger-php registers global error and exception handlers which automatically report all unhandled exceptions to Honeybadger. These handlers can be disabled via the following configuration options:

[
'handlers' => [
// Enable global exception handler
'exception' => true,
// Enable global error handler
'error' => true,
]
]

To catch an exception and notify Honeybadger without re-throwing:

try {
throw new Exception('Whoops!');
} catch (Exception $e) {
$honeybadger->notify($e);
}

You can call $honeybadger->notify() anywhere in your code where you have an Exception to report.

You can optionally include a \Symfony\Component\HttpFoundation\Request::class request as the second argument to $honeybadger->notify():

$honeybadger->notify($e, $app->request());

When the request is included, HTTP information such as params, headers, and session data will be sent to Honeybadger.

To notify Honeybadger of other types of errors:

$honeybadger->customNotification([
'title' => 'Special Error',
'message' => 'Special Error: a special error has occurred',
]);
Option NameDescription
titleThe title of the error (normally the class name).
messageThe error message.