Class: Racknga::Middleware::ExceptionNotifier
- Inherits:
-
Object
- Object
- Racknga::Middleware::ExceptionNotifier
- Defined in:
- lib/racknga/middleware/exception_notifier.rb
Overview
This is a middleware that mails exception details on error. It’s useful for finding your Rack application troubles.
Usage:
require "racknga"
= {
:subject_label => "[YourApplication]",
:from => "[email protected]",
:to => "[email protected]",
}
notifiers = [Racknga::ExceptionMailNotifier.new()]
use Racknga::Middleware::ExceptionNotifier, :notifiers => notifiers
run YourApplication
Instance Method Summary collapse
-
#call(environment) ⇒ Object
For Rack.
-
#initialize(application, options = {}) ⇒ ExceptionNotifier
constructor
A new instance of ExceptionNotifier.
Constructor Details
#initialize(application, options = {}) ⇒ ExceptionNotifier
Returns a new instance of ExceptionNotifier.
39 40 41 42 43 |
# File 'lib/racknga/middleware/exception_notifier.rb', line 39 def initialize(application, ={}) @application = application @options = Utils.( || {}) @notifiers = @options[:notifiers] || [] end |
Instance Method Details
#call(environment) ⇒ Object
For Rack.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/racknga/middleware/exception_notifier.rb', line 46 def call(environment) @application.call(environment) rescue Exception => exception @notifiers.each do |notifier| begin notifier.notify(exception, environment) rescue Exception begin $stderr.puts("#{$!.class}: #{$!.}") $stderr.puts($@) $stderr.puts("-" * 10) $stderr.puts("#{exception.class}: #{exception.}") $stderr.puts(exception.backtrace) rescue Exception end end end raise end |