Module: Roda::RodaPlugins::ErrorEmail::InstanceMethods
- Defined in:
- lib/roda/plugins/error_email.rb
Instance Method Summary collapse
-
#error_email(exception) ⇒ Object
Send an email for the given error.
-
#error_email_content(exception) ⇒ Object
The content of the email to send, include the headers and the body.
Instance Method Details
#error_email(exception) ⇒ Object
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.
131 132 133 134 135 |
# File 'lib/roda/plugins/error_email.rb', line 131 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 |
#error_email_content(exception) ⇒ Object
The content of the email to send, include the headers and the body. Takes the same argument as #error_email.
139 140 141 142 143 144 145 146 |
# File 'lib/roda/plugins/error_email.rb', line 139 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 |