Read more

exception_notification: Send exception mails in models

Thomas Eisenbarth
September 24, 2012Software engineer at makandra GmbH

You're using exception_notification Show archive.org snapshot and want to send exception mails within a model. Here's how.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

The ExceptionNotifier class has a method notify_exception for that. Simply pass an exception:

ExceptionNotifier.notify_exception Exception.new("testfoo")

=> #<Mail::Message:77493640, Multipart: false, Headers: <Date: Mon, 24 Sep 2012 13:37:00 +0200>,
<From: foo@example.com>,
<To: ["fail@failtrain.com", "fail@failbus.org"]>,
<Message-ID: <5060543b3759_212311986a0305e8@ip-10-234-82-125.mail>>,
<Subject: [you failed.]  (Exception) "testfoo">,
<Mime-Version: 1.0>,
<Content-Type: text/plain>,
<Content-Transfer-Encoding: 7bit>>

Old versions of exception_notifications

It used to be a different method:

ExceptionNotifier::Notifier.background_exception_notification Exception.new("testfoo")
Posted by Thomas Eisenbarth to makandra dev (2012-09-24 17:38)