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 web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
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)