Class: Pakyow::Fail::Handlers::Mail

Inherits:
Object
  • Object
show all
Defined in:
lib/pakyow-fail-mail.rb

Constant Summary collapse

NICENAME =
:mail

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Mail

Returns a new instance of Mail.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pakyow-fail-mail.rb', line 14

def initialize(app)
  req = app.req

  body = []
  body << "<strong>#{req.method.upcase} #{req.path} (#{req.error.class.name}) #{CGI.escapeHTML(req.error.message)}</strong>"
  body << "Params: #{app.params}"
  body << "Session: #{app.session}"
  body.concat(req.error.backtrace)

  mail = Mailer.new(content: body.join('<br>'))
  mail.message.subject = "#{Config.fail.mail_sender}: (#{req.error.class.name}) #{req.error.message}"
  mail.deliver_to Config.fail.mail_to
end