Class: Sappy::Responses::ErrorResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/sappy/responses/error.rb

Defined Under Namespace

Classes: AuthenticationError, Error

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ ErrorResponse

Returns a new instance of ErrorResponse.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sappy/responses/error.rb', line 7

def initialize(xml)
  err = xml["err"]
  message = err.first["msg"]

  case code = err.first["code"]
  when "AUTH_EXPIRED"
    raise AuthenticationExpired, message
  when "AUTH_ERR"
    raise AuthenticationError, message
  else
    raise Error, "Unknown error[#{code}]: #{message}"
  end
end