Class: Exceptron::Middleware
- Inherits:
-
Object
- Object
- Exceptron::Middleware
- Defined in:
- lib/exceptron/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, consider_all_requests_local) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, consider_all_requests_local) ⇒ Middleware
Returns a new instance of Middleware.
3 4 5 6 |
# File 'lib/exceptron/middleware.rb', line 3 def initialize(app, consider_all_requests_local) @app = app @dispatcher = Dispatcher.new(consider_all_requests_local) end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/exceptron/middleware.rb', line 8 def call(env) begin status, headers, body = @app.call(env) exception = nil # Only this middleware cares about RoutingError. So, let's just raise # it here. if headers['X-Cascade'] == 'pass' raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}" end rescue Exception => exception raise exception unless Exceptron.enabled? exception = Presenter.new(exception) env["exceptron.presenter"] = exception end exception ? @dispatcher.dispatch(env, exception) : [status, headers, body] end |