class Faraday::Error
Faraday error base class.
def backtrace
def backtrace if @wrapped_exception @wrapped_exception.backtrace else super end end
def exc_msg_and_response(exc, response = nil)
def exc_msg_and_response(exc, response = nil) return [exc, exc.message, response] if exc.respond_to?(:backtrace) return [nil, "the server responded with status #{exc[:status]}", exc] \ if exc.respond_to?(:each_key) [nil, exc.to_s, response] end
def exc_msg_and_response!(exc, response = nil)
If a subclass has to call this, then it should pass a string message
:body - String HTTP request body.
header values.
:headers - String key/value hash of HTTP request
present in the request.
:params - String key/value hash of query params
:url_path - String with the url path requested.
:url - URI object with the url requested.
:method - Symbol with the request HTTP method.
:request - Hash
:body - Optional string HTTP response body.
values.
:headers - String key/value hash of HTTP response header
:status - Optional integer HTTP response status
response - Hash
exc - Either an Exception, a string message, or a response hash.
instance variables.
Pulls out potential parent exception and response hash, storing them in
def exc_msg_and_response!(exc, response = nil) if @response.nil? && @wrapped_exception.nil? @wrapped_exception, msg, @response = exc_msg_and_response(exc, response) return msg end exc.to_s end
def initialize(exc = nil, response = nil)
def initialize(exc = nil, response = nil) @wrapped_exception = nil unless defined?(@wrapped_exception) @response = nil unless defined?(@response) super(exc_msg_and_response!(exc, response)) end
def inspect
def inspect inner = +'' inner << " wrapped=#{@wrapped_exception.inspect}" if @wrapped_exception inner << " response=#{@response.inspect}" if @response inner << " #{super}" if inner.empty? %(#<#{self.class}#{inner}>) end
def response_body
def response_body @response[:body] if @response end
def response_headers
def response_headers @response[:headers] if @response end
def response_status
def response_status @response[:status] if @response end