Class: ThreeScale::Backend::Rack::ExceptionCatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/3scale/backend/rack/exception_catcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ExceptionCatcher

Returns a new instance of ExceptionCatcher.



35
36
37
# File 'lib/3scale/backend/rack/exception_catcher.rb', line 35

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/3scale/backend/rack/exception_catcher.rb', line 39

def call(env)
  resp = @app.call(env)
  filter_encoding_error_response resp, env
rescue Backend::Error => e
  delete_sinatra_error! env
  respond_with e.http_code, prepare_body(e.to_xml, env)
rescue Exception => e
  unhandled_exception(e)
end