Parent

Methods

Rack::MailExceptions

Catches all exceptions raised from the app it wraps and sends a useful email with the exception, stacktrace, and contents of the environment.

Constants

TEMPLATE

Attributes

config[R]

Public Class Methods

new(app) click to toggle source
# File lib/rack/contrib/mailexceptions.rb, line 13
def initialize(app)
  @app = app
  @config = {
    :to      => nil,
    :from    => ENV['USER'] || 'rack',
    :subject => '[exception] %s',
    :smtp    => {
      :server         => 'localhost',
      :domain         => 'localhost',
      :port           => 25,
      :authentication => :login,
      :user_name      => nil,
      :password       => nil
    }
  }
  @template = ERB.new(TEMPLATE)
  yield self if block_given?
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/contrib/mailexceptions.rb, line 32
def call(env)
  status, headers, body =
    begin
      @app.call(env)
    rescue => boom
      # TODO don't allow exceptions from send_notification to
      # propogate
      send_notification boom, env
      raise
    end
  send_notification env['mail.exception'], env if env['mail.exception']
  [status, headers, body]
end
smtp(settings={}) click to toggle source
# File lib/rack/contrib/mailexceptions.rb, line 50
def smtp(settings={})
  @config[:smtp].merge! settings
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.