Class: Response::BrandwatchError

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/response/brandwatch_error.rb

Constant Summary collapse

ERROR_MAP =
{
  400 => BWAPI::BadRequest,
  401 => BWAPI::Unauthorized,
  403 => BWAPI::Forbidden,
  404 => BWAPI::NotFound,
  406 => BWAPI::NotAcceptable,
  422 => BWAPI::UnprocessableEntity,
  429 => BWAPI::TooManyRequests,
  500 => BWAPI::InternalServerError,
  501 => BWAPI::NotImplemented,
  502 => BWAPI::BadGateway,
  503 => BWAPI::ServiceUnavailable
}

Instance Method Summary collapse

Instance Method Details

#on_complete(response) ⇒ Object

Raises:



20
21
22
23
# File 'lib/faraday/response/brandwatch_error.rb', line 20

def on_complete(response)
  key = response[:status].to_i
  raise ERROR_MAP[key].new(response) if ERROR_MAP.has_key? key
end