Catches all exceptions raised from the app it wraps and sends a useful email with the exception, stacktrace, and contents of the environment.
# 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
# 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
Generated with the Darkfish Rdoc Generator 2.