module Roda::RodaPlugins::ErrorEmail::InstanceMethods

  1. lib/roda/plugins/error_email.rb


Public Instance

  1. error_email
  2. error_email_content

Public Instance methods


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
122 def error_email(exception)
123   email_opts = self.class.opts[:error_email].dup
124   email_opts[:message] = error_email_content(exception)
125   email_opts[:emailer].call(email_opts)
126 end

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
130 def error_email_content(exception)
131   email_opts = self.class.opts[:error_email]
132   headers = email_opts[:default_headers].call(email_opts, exception)
133   headers = headers.merge(email_opts[:headers])
134   headers ={|k,v| "#{k}: #{v.gsub(/\r?\n/m, "\r\n ")}"}.sort.join("\r\n")
135   body = email_opts[:body].call(self, exception)
136   "#{headers}\r\n\r\n#{body}"
137 end