Module: Telesign::Exceptions

Defined in:
lib/telesign/lib/exceptions.rb

Defined Under Namespace

Classes: TelesignError

Constant Summary collapse

EXCEPTIONAL_ERRORS =
{
  -10001 => InvalidParameter,
  -20001 => InvalidCustomerID,
  -20002 => InvalidReferenceID,
  -30001 => AccountSuspended,
  -40001 => StatusUnavailable,
  -50001 => MaxRetriesReached,
  -80001 => SystemUnavailable,
  -90001 => SystemUnavailable
}

Class Method Summary collapse

Class Method Details

.raise_if_error(api_error) ⇒ Object



22
23
24
25
26
# File 'lib/telesign/lib/exceptions.rb', line 22

def self.raise_if_error(api_error)
  if api_error && EXCEPTIONAL_ERRORS[api_error.code]
    raise EXCEPTIONAL_ERRORS[api_error.code].new(api_error.message)
  end
end