class Faraday::Error
Faraday
error base class.
Attributes
Public Class Methods
Source
# File lib/faraday/error.rb, line 9 def initialize(exc, response = nil) @wrapped_exception = nil unless defined?(@wrapped_exception) @response = nil unless defined?(@response) super(exc_msg_and_response!(exc, response)) end
Calls superclass method
Public Instance Methods
Source
# File lib/faraday/error.rb, line 15 def backtrace if @wrapped_exception @wrapped_exception.backtrace else super end end
Calls superclass method
Source
# File lib/faraday/error.rb, line 23 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
Protected Instance Methods
Source
# File lib/faraday/error.rb, line 54 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
Pulls out potential parent exception and response hash.
Source
# File lib/faraday/error.rb, line 44 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
Pulls out potential parent exception and response hash, storing them in instance variables. exc - Either an Exception, a string message, or a response hash. response - Hash
:status - Optional integer HTTP response status :headers - String key/value hash of HTTP response header values. :body - Optional string HTTP response body.
If a subclass has to call this, then it should pass a string message to ‘super`. See NilStatusError
.