Sometimes there are errors that you would rather not send to Honeybadger because they are not actionable or are handled internally. The honeybadger gem has multiple ways to ignore errors, depending on the situation:
Ignore by Class
Some exceptions aren't very useful and are best ignored. By default, we ignore the following:
AbstractController::ActionNotFound ActionController::BadRequest ActionController::InvalidAuthenticityToken ActionController::InvalidCrossOriginRequest ActionController::MethodNotAllowed ActionController::NotImplemented ActionController::ParameterMissing ActionController::RoutingError ActionController::UnknownAction ActionController::UnknownFormat ActionController::UnknownHttpMethod ActionDispatch::ParamsParser::ParseError ActiveRecord::RecordNotFound CGI::Session::CookieStore::TamperedWithCookie Mongoid::Errors::DocumentNotFound Sinatra::NotFound
To ignore additional errors, use the
exceptions.ignore configuration option.
The gem will ignore any exceptions matching the string, regex or class that you
exceptions: ignore: - 'MyError' - !ruby/regexp '/Ignored$/' - !ruby/class 'IgnoredError'
Subclasses of ignored classes will also be ignored, while strings and regexps are compared with the error class name only.
To override the default ignored exceptions, use the exceptions.ignore_only option instead:
exceptions: ignore_only: - 'MyError'
In this case only the MyError class will be ignored, and all the classes that were ignored by default will no longer be ignored.
Ignore by Browser
To ignore certain user agents, use the
option. You can specify strings or regular expressions:
exceptions: ignored_user_agents: - 'Exact User Agent' - !ruby/regexp '/Bing/i'
Ignore by Environment
Honeybadger ignores errors in development and test environments by default. You
can enable or disable error reporting for a specific environment by using the
[environment name].report_data configuration option:
staging: report_data: false
You may alternatively set
HONEYBADGER_REPORT_DATA=false in your app's ENV.
We ask that you not enable error reporting for your test environment. It doesn't do anyone any good. :)
To ignore errors with some custom logic, you can use the
before_notify callback. This method lets you add a callback
that will be run every time an exception is about to be reported to Honeybadger.
If your callback calls the
notice.halt! method, the exception won't be reported:
# Here's how you might ignore exceptions based on their error message: Honeybadger.configure do |config| config.before_notify do |notice| notice.halt! if notice.error_message =~ /sensitive data/ end end
You can access any attribute on the
notice argument by using the
Honeybadger.configure do |config| config.before_notify do |notice| notice.halt! if notice.exception.class < MyError && notice.params[:name] =~ "bob" && notice.context[:current_user_id] != 1 end end