module Roda::RodaPlugins::ErrorMail::InstanceMethods
def _error_mail(e)
def _error_mail(e) email_opts = self.class.opts[:error_mail] subject = if e.respond_to?(:message) "#{e.class}: #{e.message}" else e.to_s end subject = "#{email_opts[:prefix]}#{subject}" format = lambda{|h| h.map{|k, v| "#{k.inspect} => #{v.inspect}"}.sort.join("\n")} message = String.new message << <<END request.path} if e.respond_to?(:backtrace) message << <<END e: trace.join("\n")} end message << <<END [env]} unless request.params.empty? message << <<END [request.params]} end if env['rack.session'] message << <<END [session]} end Mail.new do from email_opts[:from] to email_opts[:to] subject subject body message if headers = email_opts[:headers] headers.each do |k,v| header[k] = v end end end end
def error_mail(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_mail(exception) _error_mail(exception).deliver! end
def error_mail_content(exception)
The content of the email to send, include the headers and the body.
def error_mail_content(exception) _error_mail(exception).to_s end