Class: Sheep::ErrorResponse
- Inherits:
-
Object
- Object
- Sheep::ErrorResponse
- Defined in:
- lib/sheep/error.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil) ⇒ ErrorResponse
constructor
A new instance of ErrorResponse.
Constructor Details
#initialize(app = nil) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
9 10 11 |
# File 'lib/sheep/error.rb', line 9 def initialize(app = nil) @app = app end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sheep/error.rb', line 13 def call(env) status, headers, body = @app.call(env) case status when 200, 201, 301, 302 when 400 raise Sheep::BadRequest.new(body['error'] || body['errors']) when 404 raise Sheep::NotFound else raise Sheep::UnknownError.new(body) end return status, headers, body end |