Exception: USPS::Error

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

Overview

Direct Known Subclasses

AuthorizationError, ValidationError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, number, source) ⇒ Error

Returns a new instance of Error.



16
17
18
19
20
21
# File 'lib/usps/errors.rb', line 16

def initialize(message, number, source)
  super(message)

  @number = number
  @source = source
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



14
15
16
# File 'lib/usps/errors.rb', line 14

def number
  @number
end

#sourceObject (readonly)

Returns the value of attribute source.



14
15
16
# File 'lib/usps/errors.rb', line 14

def source
  @source
end

Class Method Details

.for_code(code) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/usps/errors.rb', line 24

def for_code(code)
  case code
  when '80040b1a'   ; AuthorizationError
  when '-2147219400'; InvalidCityError
  when '-2147219401'; AddressNotFoundError
  when '-2147219402'; InvalidStateError
  when '-2147219403'; MultipleAddressError
  when '-2147218900'; InvalidImageTypeError
  else              ; Error
  end
end