Reporting errors
Honeybadger reports uncaught exceptions automatically. In all other cases, use
$honeybadger->notify() and $honeybadger->customNotification() to send errors
to Honeybadger.
Reporting unhandled exceptions
Section titled “Reporting unhandled exceptions”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, ]]Reporting handled exceptions
Section titled “Reporting handled exceptions”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.
Including request data
Section titled “Including request data”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.
Sending custom notifications
Section titled “Sending custom notifications”To notify Honeybadger of other types of errors:
$honeybadger->customNotification([ 'title' => 'Special Error', 'message' => 'Special Error: a special error has occurred',]);Options
Section titled “Options”| Option Name | Description |
|---|---|
| title | The title of the error (normally the class name). |
| message | The error message. |