lib/jt-rails-toolbox.rb in jt-rails-toolbox-2.2.0 vs lib/jt-rails-toolbox.rb in jt-rails-toolbox-2.2.1
- old
+ new
@@ -73,12 +73,14 @@
require 'exception_notification'
require 'exception_notification/rails'
require 'exception_notification/sidekiq'
+ exceptions_to_ignore = %w{ActionController::InvalidCrossOriginRequest ActionController::InvalidAuthenticityToken}
+
ExceptionNotification.configure do |config|
- config.ignored_exceptions += ['ActionController::InvalidCrossOriginRequest', 'ActionController::InvalidAuthenticityToken']
+ config.ignored_exceptions += exceptions_to_ignore
if !@params['exception']['slack_webhook_url'].blank?
config.add_notifier :slack, {
webhook_url: params['exception']['slack_webhook_url'],
}
@@ -98,22 +100,35 @@
return if @params['airbrake'].nil?
require 'airbrake'
require 'airbrake/sidekiq/error_handler'
+ # Default ignored exceptions in Exception Notification
+ exceptions_to_ignore = %w{ActiveRecord::RecordNotFound Mongoid::Errors::DocumentNotFound AbstractController::ActionNotFound ActionController::RoutingError ActionController::UnknownFormat ActionController::UrlGenerationError}
+
+ # Additionnal exceptions to ignore
+ exceptions_to_ignore.push *%w{ActionController::InvalidCrossOriginRequest ActionController::InvalidAuthenticityToken}
+
Airbrake.configure do |c|
if @params['airbrake']['host']
c.host = @params['airbrake']['host']
end
c.project_id = @params['airbrake']['project_id']
c.project_key = @params['airbrake']['project_key']
+
c.environment = Rails.env
if @params['airbrake']['ignore_environments']
c.ignore_environments = @params['airbrake']['ignore_environments']
else
c.ignore_environments = %w(development test)
+ end
+ end
+
+ Airbrake.add_filter do |notice|
+ if notice[:errors].any? { |error| exceptions_to_ignore.include?(error[:type]) }
+ notice.ignore!
end
end
end
def configure_mail(app)
\ No newline at end of file