Method: Laposta::Error.from_response
- Defined in:
- lib/laposta/error.rb
.from_response(response) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/laposta/error.rb', line 3 def self.from_response(response) error_class = case response.status when 301 then LoginDoesNotExistError # This login does not exist when 302 then InvalidPasswordError # The password entered is incorrect when 303 then UserNotAllowedToLoginError # This user is not (or no longer) allowed to log in when 304 then AccountNotAllowedToLoginError # This account is not (or no longer) allowed to log in when 305 then AccountNotVerifiedError # This account has not been verified when 400 then BadRequestError # Incomplete input when 401 then UnauthorizedError # No valid API key was provided when 402 then RequestFailedError # Input was in order, but request was not processed when 404 then NotFoundError # The requested object does not exist/could not be located when 429 then TooManyRequestsError # The maximum number of requests was reached within the given unit of time when 500 then ServerError # Error detected on Laposta's side else self end error_class.new(response) end |