Class: BreweryDB::Middleware::ErrorHandler

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/brewery_db/middleware/error_handler.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/brewery_db/middleware/error_handler.rb', line 4

def on_complete(env)
  case env[:status]
    when 200
    when 400 then fail with(BadRequest, env)
    when 401 then fail with(rate_limit_exceeded_or_unauthorized(env[:response_headers]), env)
    when 404 then fail with(NotFound, env)
    else fail with(Error, env)
  end
end