class TrackerApi::Error

Attributes

response[R]
wrapped_exception[R]

Public Class Methods

new(wrapped_exception) click to toggle source
Calls superclass method
# File lib/tracker_api/error.rb, line 5
def initialize(wrapped_exception)
  @wrapped_exception = wrapped_exception
  @response          = wrapped_exception.response
  message            = if wrapped_exception.is_a?(Faraday::ParsingError)
                         wrapped_exception.message
                       elsif faraday_response_error?(wrapped_exception)
                         wrapped_exception.response.inspect
                       else
                         wrapped_exception.instance_variable_get(:@wrapped_exception).inspect
                       end
  super(message)
end

Private Instance Methods

faraday_response_error?(wrapped_exception) click to toggle source

faraday 16.0 re-organized their errors. The errors we're interested in, Faraday::ClientError before 16.0 and Faraday::ServerError introduced in 16.0, are represented by this conditional.

# File lib/tracker_api/error.rb, line 23
def faraday_response_error?(wrapped_exception)
  wrapped_exception.is_a?(Faraday::Error) &&
    wrapped_exception.respond_to?(:response)
end