Class: Rack::JsonSchema::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/json_schema/error_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ErrorHandler

Behaves as a rack middleware

Parameters:

  • app (Object)

    Rack application


6
7
8
# File 'lib/rack/json_schema/error_handler.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Behaves as a rack middleware

Parameters:

  • env (Hash)

    Rack env


12
13
14
15
16
# File 'lib/rack/json_schema/error_handler.rb', line 12

def call(env)
  @app.call(env)
rescue Rack::JsonSchema::Error => exception
  exception.to_rack_response
end