Class: Rack::Builder

Inherits:
Object show all
Defined in:
lib/waw/ext/rack/builder.rb

Instance Method Summary collapse

Instance Method Details

#error_handler(*args, &block) ⇒ Object

Adds or push an error handler on top of the application chain.

The method accepts the following argument variants:

error_handler{|k,ex| ... }
error_handler(SomeValidator){|k,ex| ... }
error_handler(SomeHandler)
error_handler(SomeValidator, SomeHandler)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/waw/ext/rack/builder.rb', line 14

def error_handler(*args, &block)
  @ins << lambda{|app| 
    if ::Waw::ErrorHandler === app
      app.unshift(*args, &block)
      app
    else
      handler = ::Waw::ErrorHandler.new(app)
      handler.push(*args, &block)
      handler
    end
  }
end