module Roda::RodaPlugins::ErrorEmail::InstanceMethods

  1. lib/roda/plugins/error_email.rb

Methods

Public Instance

  1. error_email
  2. error_email_content

Public Instance methods

error_email(exception)

Send an email for the given error. exception is usually an exception instance, but it can be a plain string which is used as the subject for the email.

[show source]
    # File lib/roda/plugins/error_email.rb
131 def error_email(exception)
132   email_opts = self.class.opts[:error_email].dup
133   email_opts[:message] = error_email_content(exception)
134   email_opts[:emailer].call(email_opts)
135 end
error_email_content(exception)

The content of the email to send, include the headers and the body. Takes the same argument as error_email.

[show source]
    # File lib/roda/plugins/error_email.rb
139 def error_email_content(exception)
140   email_opts = self.class.opts[:error_email]
141   headers = email_opts[:default_headers].call(email_opts, exception)
142   headers = headers.merge(email_opts[:headers])
143   headers = headers.map{|k,v| "#{k}: #{v.gsub(/\r?\n/m, "\r\n ")}"}.sort.join("\r\n")
144   body = email_opts[:body].call(self, exception)
145   "#{headers}\r\n\r\n#{body}"
146 end