Class: Rack::MailException

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/mail_exception.rb

Constant Summary collapse

VERSION =
"0.0.1"
FILTERING =
%(['"]?%s['"]?=>?([^&\s]*))

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ MailException

Returns a new instance of MailException.



20
21
22
23
24
25
26
27
# File 'lib/rack/mail_exception.rb', line 20

def initialize(app, options = {})
  @to      = options[:to]      || raise(ArgumentError, ":to is required")
  @from    = options[:from]    || raise(ArgumentError, ":from is required")
  @subject = options[:subject] || "[Application Exception] %s"

  @filters = Array(options[:filters])
  @app     = app
end

Instance Method Details

#call(env) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rack/mail_exception.rb', line 29

def call(env)
  status, headers, body =
    begin
      @app.call(env)
    rescue Exception => ex
      notify ex, env
      raise ex
    end

  [status, headers, body]
end