exception_notification: Send exception mails in models

Updated . Posted . Visible to the public.

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

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")
Profile picture of Thomas Eisenbarth
Thomas Eisenbarth
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Thomas Eisenbarth to makandra dev (2012-09-24 15:38)