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}" filter = email_opts[:filter] format = lambda do |h| h = h.map{|k, v| "#{k.inspect} => #{filter.call(k, v) ? 'FILTERED' : v.inspect}"} h.sort! h.join("\n") end begin params = request.params params = (format[params] unless params.empty?) rescue params = 'Invalid Parameters!' end message = String.new message << <<END request.path} if e.respond_to?(:backtrace) message << <<END e: trace.join("\n")} end message << <<END [env]} if params message << <<END } 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