module Roda::RodaPlugins::ErrorEmail::InstanceMethods
def error_email(exception)
instance, but it can be a plain string which is used as the subject for
Send an email for the given error. +exception+ is usually an exception
def error_email(exception) email_opts = self.class.opts[:error_email].dup email_opts[:message] = error_email_content(exception) email_opts[:emailer].call(email_opts) end
def error_email_content(exception)
The content of the email to send, include the headers and the body.
def error_email_content(exception) email_opts = self.class.opts[:error_email] headers = email_opts[:default_headers].call(email_opts, exception) headers = headers.merge(email_opts[:headers]) headers = headers.map{|k,v| "#{k}: #{v.gsub(/\r?\n/m, "\r\n ")}"}.sort.join("\r\n") body = email_opts[:body].call(self, exception) "#{headers}\r\n\r\n#{body}" end