module Roda::RodaPlugins::ErrorMail

  1. lib/roda/plugins/error_mail.rb

The error_mail plugin adds an error_mail instance method that send an email related to the exception. This is most useful if you are also using the error_handler plugin:

plugin :error_mail, to: '', from: ''
plugin :error_handler do |e|
  'Internal Server Error'

It is similar to the error_email plugin, except that it uses the mail library instead of net/smtp directly. If you are already using the mail library in your application, it makes sense to use error_mail instead of error_email.



The From address to use in the email (required)


A hash of additional headers to use in the email (default: empty hash)


A prefix to use in the email’s subject line (default: no prefix)


The To address to use in the email (required)

The subject of the error email shows the exception class and message. The body of the error email shows the backtrace of the error and the request environment, as well the request params and session variables (if any). You can also call error_mail with a plain string instead of an exception, in which case the string is used as the subject, and no backtrace is included.

Note that emailing on every error as shown above is only appropriate for low traffic web applications. For high traffic web applications, use an error reporting service instead of this plugin.


Public Class

  1. configure

Public Class methods

configure(app, opts=OPTS)

Set default opts for plugin. See ErrorEmail module RDoc for options.

[show source]
   # File lib/roda/plugins/error_mail.rb
40 def self.configure(app, opts=OPTS)
41   app.opts[:error_mail] = email_opts = (app.opts[:error_mail] || OPTS).merge(opts).freeze
42   unless email_opts[:to] && email_opts[:from]
43     raise RodaError, "must provide :to and :from options to error_mail plugin"
44   end
45 end