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

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:

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

Reporting Handled Exceptions

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

php
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

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

php
$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

To notify Honeybadger of other types of errors:

php
$honeybadger->customNotification([ 'title' => 'Special Error', 'message' => 'Special Error: a special error has occurred', ]);

Options

Option Name Description
title The title of the error (normally the class name).
message The error message.