Exception: VWorkApp::ResponseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/vworkapp_ruby/base/response_error.rb

Overview

Error raised on a bad response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(res) ⇒ ResponseError

Returns a new instance of ResponseError.



7
8
9
10
11
# File 'lib/vworkapp_ruby/base/response_error.rb', line 7

def initialize(res)
  @response = res.response
  @code     = res.response.code
  @errors   = extract_errors(res.parsed_response)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/vworkapp_ruby/base/response_error.rb', line 5

def code
  @code
end

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/vworkapp_ruby/base/response_error.rb', line 5

def errors
  @errors
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/vworkapp_ruby/base/response_error.rb', line 5

def response
  @response
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/vworkapp_ruby/base/response_error.rb', line 13

def to_s
  "#{code.to_s} - #{response.msg}:\n#{@errors && @errors.join("\n")}".strip
end