Exception: Zedkit::Client::ClientError

Inherits:
ZedkitError
  • Object
show all
Defined in:
lib/zedkit/client/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info = {}) ⇒ ClientError

Returns a new instance of ClientError.



26
27
28
29
30
31
# File 'lib/zedkit/client/exceptions.rb', line 26

def initialize(info = {})
  @http_code = info[:http_code] || 0
  @api_code  = info[:api_code]  || nil
  @message   = info[:message]   || nil
  @errors    = info[:errors]    || nil
end

Instance Attribute Details

#api_codeObject (readonly)

Returns the value of attribute api_code.



24
25
26
# File 'lib/zedkit/client/exceptions.rb', line 24

def api_code
  @api_code
end

#errorsObject (readonly)

Returns the value of attribute errors.



24
25
26
# File 'lib/zedkit/client/exceptions.rb', line 24

def errors
  @errors
end

#http_codeObject (readonly)

Returns the value of attribute http_code.



24
25
26
# File 'lib/zedkit/client/exceptions.rb', line 24

def http_code
  @http_code
end

#messageObject (readonly)

Returns the value of attribute message.



24
25
26
# File 'lib/zedkit/client/exceptions.rb', line 24

def message
  @message
end

Instance Method Details

#to_sObject



33
34
35
36
37
38
39
40
# File 'lib/zedkit/client/exceptions.rb', line 33

def to_s
  rs  = "\nZedkit API Error Response.\n" \
     << "  HTTP Code => #{http_code}. #{http_string(http_code)}\n"
  rs << "  API Status Code => #{api_code}.\n" unless api_code.nil?
  rs << "  API Response Message => #{message}.\n" unless message.nil?
  rs << "  API Error Attribute Details => #{@errors['attributes'].map {|k,v| "#{k} => #{v}" }}.\n" unless errors.nil?
  rs << "\n"
end