Reducing noise
Sometimes there are errors that you would rather not send to Honeybadger because they are not actionable or are handled internally.
In Honeybadger, you can
ignore exceptions by type using the built-in
excluded_exceptions configuration option, as well as the $dontReport option
in Laravel. You can also disable error reporting in all or some
environments.
Ignoring exceptions by type
Section titled “Ignoring exceptions by type”There may be some types of exceptions which you never want to report. To ignore
them, use the excluded_exceptions
configuration option:
[ 'excluded_exceptions' => [ SomeException::class, AnotherException::class, ],]Laravel
Section titled “Laravel”If you’re using Laravel, Honeybadger respects
the $dontReport property of Laravel’s
exception handler
when automatically reporting exceptions during web requests. This means that any
exceptions which are ignored by Laravel will also be ignored by Honeybadger. You
may add other exception types to this array as needed:
/** * A list of the exception types that should not be reported. * * @var array */protected $dontReport = [ \Illuminate\Auth\AuthenticationException::class, \Illuminate\Auth\Access\AuthorizationException::class, \Symfony\Component\HttpKernel\Exception\HttpException::class, \Illuminate\Database\Eloquent\ModelNotFoundException::class, \Illuminate\Validation\ValidationException::class,];Keep in mind that Honeybadger will still report exceptions on this list if they are reported outside of Laravel’s exception handler, such as when reporting handled exceptions.
Ignoring exceptions programmatically
Section titled “Ignoring exceptions programmatically”You can use the beforeNotify callback to ignore exceptions programmatically.
This callback is called before an exception is sent to Honeybadger. If the
callback returns false, the exception will not be reported.
For example, you can ignore exceptions based on the exception message:
$honeybadger->beforeNotify(function (&$notice) { if (strpos($notice['error']['message'], 'Ignore this exception') !== false) { return false; }});Or, you may modify the fingerprint of the exception to group it with other similar exceptions:
$honeybadger->beforeNotify(function (&$notice) { $notice['error']['fingerprint'] = 'MyFingerprint';});Note: You can register multiple beforeNotify callbacks. If any of them
return false, the exception will not be reported.
Notice properties
Section titled “Notice properties”The $notice parameter is an associative array that contains the following
keys:
breadcrumbsenabled: Indicates if breadcrumbs are enabled, fetched from the configurationtrail: The breadcrumb trail converted to an array of associative arrays, each containing:message: The message of the breadcrumbcategory: The category of the breadcrumbmetadata: An associative array of metadata for the breadcrumbtimestamp: The timestamp of the breadcrumb
errorclass: The type of the exception.message: The exception message.backtrace: The backtrace of the exception.causes: The previous exceptions in the backtrace.fingerprint: A grouping identifier for the error, if provided.tags: Tags associated with the error, wrapped in an array.
requestcgi_data: CGI data from the environment, or an empty object if not available.params: Request parameters, or an empty object if not available.session: Session data, or an empty object if not available.url: The request URL.context: Context data or an empty object if not available.component: The component name, either from additional parameters or context.action: The action name, either from additional parameters or context.
serverpid: The process ID.version: The application version.hostname: The hostname of the server.project_root: The root directory of the project.environment_name: The name of the environment.
Disabling error reporting
Section titled “Disabling error reporting”You can disable error reporting completely by setting the report_data config
option to false. For example, the default Laravel config has this as:
'report_data' => ! in_array(env('APP_ENV'), ['local', 'testing']),This means exceptions won’t be reported to Honeybadger in local and testing
environments. If you want to change that, you can easily add or remove
environments or set report_data to true.