Exception: CloudApp::ResponseError

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

Overview

Error raised on a bad response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(res) ⇒ CloudApp::ResponseError

Instantiate an instance of CloudApp::ResponseError

Only used internally

Parameters:


14
15
16
17
18
19
20
21
22
# File 'lib/cloudapp/response_error.rb', line 14

def initialize(res)
  @response = res.response
  @code     = res.code
  begin
    @errors = parse_errors(res.parsed_response)
  rescue JSON::ParserError => ex
    @errors = [res.response.body]
  end
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code


6
7
8
# File 'lib/cloudapp/response_error.rb', line 6

def code
  @code
end

#errorsObject (readonly)

Returns the value of attribute errors


6
7
8
# File 'lib/cloudapp/response_error.rb', line 6

def errors
  @errors
end

#responseObject (readonly)

Returns the value of attribute response


6
7
8
# File 'lib/cloudapp/response_error.rb', line 6

def response
  @response
end

Instance Method Details

#to_sString

Returns error code and message

Returns:

  • (String)

27
28
29
# File 'lib/cloudapp/response_error.rb', line 27

def to_s
  "#{code.to_s} #{response.msg}".strip
end