Class: Upfluence::HTTP::Middleware::HandleException

Inherits:
Object
  • Object
show all
Defined in:
lib/upfluence/http/middleware/handle_exception.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ HandleException

Returns a new instance of HandleException.



5
6
7
# File 'lib/upfluence/http/middleware/handle_exception.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
# File 'lib/upfluence/http/middleware/handle_exception.rb', line 9

def call(env)
  @app.call(env)
rescue StandardError, LoadError, SyntaxError => e
  [500, {}, ["{\"error\": \"#{e.class.name}\"}"]]
end