Class: FakeSQS::CatchErrors

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_sqs/catch_errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ CatchErrors

Returns a new instance of CatchErrors.



6
7
8
9
# File 'lib/fake_sqs/catch_errors.rb', line 6

def initialize(app, options = {})
  @app = app
  @response = options.fetch(:response)
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
# File 'lib/fake_sqs/catch_errors.rb', line 11

def call(env)
  @app.call(env)
rescue => error
  response = @response.new(error)
  [ response.status, {}, [ response.body ] ]
end