Exception: Flexirest::HTTPException

Inherits:
RequestException show all
Defined in:
lib/flexirest/request.rb

Direct Known Subclasses

HTTPClientException, HTTPServerException

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ HTTPException

Returns a new instance of HTTPException.



952
953
954
955
956
957
958
# File 'lib/flexirest/request.rb', line 952

def initialize(options)
  @status = options[:status]
  @result = options[:result]
  @request_url = options[:url]
  @body = options[:raw_response]
  @method = options[:method]
end

Instance Attribute Details

#bodyObject Also known as: raw_response

Returns the value of attribute body.



951
952
953
# File 'lib/flexirest/request.rb', line 951

def body
  @body
end

#request_urlObject

Returns the value of attribute request_url.



951
952
953
# File 'lib/flexirest/request.rb', line 951

def request_url
  @request_url
end

#resultObject

Returns the value of attribute result.



951
952
953
# File 'lib/flexirest/request.rb', line 951

def result
  @result
end

#statusObject

Returns the value of attribute status.



951
952
953
# File 'lib/flexirest/request.rb', line 951

def status
  @status
end

Instance Method Details

#messageObject



961
962
963
964
# File 'lib/flexirest/request.rb', line 961

def message
  method = @method.try(:upcase)
  "The #{method} to '#{@request_url}' returned a #{@status} status, which raised a #{self.class.to_s} with a body of: #{@body}"
end

#to_sObject



966
967
968
# File 'lib/flexirest/request.rb', line 966

def to_s
  message
end