Class: Cronofy::Errors

Inherits:
Object
  • Object
show all
Defined in:
lib/cronofy/errors.rb

Overview

Internal: Helper methods for raising more meaningful errors.

Constant Summary collapse

ERROR_MAP =
{
  400 => BadRequestError,
  401 => AuthenticationFailureError,
  402 => PaymentRequiredError,
  403 => AuthorizationFailureError,
  404 => NotFoundError,
  422 => InvalidRequestError,
  423 => AccountLockedError,
  429 => TooManyRequestsError,
  500 => ServerError,
  502 => BadGatewayError,
  503 => ServiceUnavailableError,
  504 => GatewayTimeoutError,
}.freeze

Class Method Summary collapse

Class Method Details

.map_error(error) ⇒ Object



103
104
105
# File 'lib/cronofy/errors.rb', line 103

def self.map_error(error)
  raise_error(error.response)
end

.raise_if_error(response) ⇒ Object



107
108
109
110
# File 'lib/cronofy/errors.rb', line 107

def self.raise_if_error(response)
  return if response.status == 200
  raise_error(response)
end