Class: BWAPI::Response::Error

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/bwapi/response/error.rb

Overview

Brandwatch response middleware to handle errors

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



22
23
24
25
# File 'lib/bwapi/response/error.rb', line 22

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