Exception: XEClient::Error

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

Direct Known Subclasses

AuthenticationError

Constant Summary collapse

CODE_ERROR_MAP =
{
  1 => "AuthenticationError",
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#codeObject

Returns the value of attribute code.



7
8
9
# File 'lib/xe_client/errors/error.rb', line 7

def code
  @code
end

Class Method Details

.new_from_response(response) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/xe_client/errors/error.rb', line 9

def self.new_from_response(response)
  return nil if response.code.nil?
  klass = if class_name = CODE_ERROR_MAP[response.code]
            XEClient.const_get(class_name)
          else
            self
          end
  error = klass.new(response.message)
  error.code = response.code
  error
end