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.



938
939
940
941
942
943
944
# File 'lib/flexirest/request.rb', line 938

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

Instance Attribute Details

#body=(value) ⇒ Object

Sets the attribute body

Parameters:

  • value

    the value to set the attribute body to.



937
938
939
# File 'lib/flexirest/request.rb', line 937

def body=(value)
  @body = value
end

#raw_responseObject Also known as: body

Returns the value of attribute raw_response.



937
938
939
# File 'lib/flexirest/request.rb', line 937

def raw_response
  @raw_response
end

#request_urlObject

Returns the value of attribute request_url.



937
938
939
# File 'lib/flexirest/request.rb', line 937

def request_url
  @request_url
end

#resultObject

Returns the value of attribute result.



937
938
939
# File 'lib/flexirest/request.rb', line 937

def result
  @result
end

#statusObject

Returns the value of attribute status.



937
938
939
# File 'lib/flexirest/request.rb', line 937

def status
  @status
end

Instance Method Details

#messageObject



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

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



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

def to_s
  message
end