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
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
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:
// app/Exceptions/Handler.php
/**
* 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
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
The $notice
parameter is an associative array that contains the following keys:
-
breadcrumbs
-
enabled
: Indicates if breadcrumbs are enabled, fetched from the configuration -
trail
: The breadcrumb trail converted to an array of associative arrays, each containing:-
message
: The message of the breadcrumb -
category
: The category of the breadcrumb -
metadata
: An associative array of metadata for the breadcrumb -
timestamp
: The timestamp of the breadcrumb
-
-
-
error
-
class
: 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.
-
-
request
-
cgi_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.
-
-
server
-
pid
: 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
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
.