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.



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

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.



949
950
951
# File 'lib/flexirest/request.rb', line 949

def body
  @body
end

#request_urlObject

Returns the value of attribute request_url.



949
950
951
# File 'lib/flexirest/request.rb', line 949

def request_url
  @request_url
end

#resultObject

Returns the value of attribute result.



949
950
951
# File 'lib/flexirest/request.rb', line 949

def result
  @result
end

#statusObject

Returns the value of attribute status.



949
950
951
# File 'lib/flexirest/request.rb', line 949

def status
  @status
end

Instance Method Details

#messageObject



959
960
961
962
# File 'lib/flexirest/request.rb', line 959

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



964
965
966
# File 'lib/flexirest/request.rb', line 964

def to_s
  message
end