Exception: Scale::HttpError

Inherits:
GenericError show all
Defined in:
lib/scale/http_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ HttpError

Returns a new instance of HttpError.



5
6
7
8
9
10
# File 'lib/scale/http_error.rb', line 5

def initialize(exception)
  @original_exception = exception
  @response = Scale.hash(JSON.parse(exception.response.body)) rescue Scale.hash()
  @status_code = response[:status_code] || e.original_exception.response.code rescue 500
  @message = response[:message] || response[:error]
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/scale/http_error.rb', line 3

def message
  @message
end

#original_exceptionObject (readonly)

Returns the value of attribute original_exception.



3
4
5
# File 'lib/scale/http_error.rb', line 3

def original_exception
  @original_exception
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/scale/http_error.rb', line 3

def response
  @response
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



3
4
5
# File 'lib/scale/http_error.rb', line 3

def status_code
  @status_code
end

Instance Method Details

#codeObject



12
13
14
# File 'lib/scale/http_error.rb', line 12

def code
  status_code
end