Exception: ShippingScale::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/shipping_scale/error.rb

Direct Known Subclasses

AuthorizationError, ValidationError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, code, source) ⇒ Error

Returns a new instance of Error.



5
6
7
8
9
10
# File 'lib/shipping_scale/error.rb', line 5

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

  @code = code
  @source = source
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



3
4
5
# File 'lib/shipping_scale/error.rb', line 3

def code
  @code
end

#sourceObject (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/shipping_scale/error.rb', line 3

def source
  @source
end

Class Method Details

.for_code(code) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/shipping_scale/error.rb', line 13

def for_code(code)
  case code 
  when "-2147219498"    ; AuthorizationError
  when "-2147219100"    ; MissingZipOriginError
  when "-2147219099"    ; MissingZipDestinationError
  when "-2147219497"    ; InvalidZipDestinationError
  when "-2147219498"    ; InvalidZipOriginError
  when "-2147219097"    ; MissingWeightError
  when "-2147219098"    ; MissingWeightError
  else                  ; Error
  end
end