Exception notifier: How to provide custom data to fail mails

Posted . Visible to the public.

The exception_notification Show archive.org snapshot gem supports to provide custom data to e.g. the fail mail within foreground or background jobs.

ExceptionNotifier.notify_exception(_ex_, :data => {:message => "was doing something wrong"})

Still this can be blocked if you have an initializer where you override the default sections and background_sections option. So remember to add the data option to the desired section if required. In case you raise an exception without a data object, the fail mail still contains an empty data section.

require 'exception_notification/rails'

ExceptionNotification.configure do |config|

  config.add_notifier :email, {
    sections: %w[data request backtrace],
    background_sections: %w[data backtrace],
  }

end

Last edit
Emanuel
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2018-11-13 14:41)