Sha256: f790e267eec579ca0d19c63728f8d50bf69c8c76a42b1c4d9f450b6019a08a92

Contents?: true

Size: 1.16 KB

Versions: 13

Compression:

Stored size: 1.16 KB

Contents

module Faraday
  class Error < StandardError; end
  class MissingDependency < Error; end

  class ClientError < Error
    attr_reader :response

    def initialize(ex, response = nil)
      @wrapped_exception = nil
      @response = response

      if ex.respond_to?(:backtrace)
        super(ex.message)
        @wrapped_exception = ex
      elsif ex.respond_to?(:each_key)
        super("the server responded with status #{ex[:status]}")
        @response = ex
      else
        super(ex.to_s)
      end
    end

    def backtrace
      if @wrapped_exception
        @wrapped_exception.backtrace
      else
        super
      end
    end

    def inspect
      %(#<#{self.class}>)
    end
  end

  class ConnectionFailed < ClientError;   end
  class ResourceNotFound < ClientError;   end
  class ParsingError     < ClientError;   end

  class TimeoutError < ClientError
    def initialize(ex = nil)
      super(ex || "timeout")
    end
  end

  class SSLError < ClientError
  end

  [:MissingDependency, :ClientError, :ConnectionFailed, :ResourceNotFound,
   :ParsingError, :TimeoutError, :SSLError].each do |const|
    Error.const_set(const, Faraday.const_get(const))
  end
end

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
mercadopago-custom-checkout-0.1.2 .gs/gems/faraday-0.9.2/lib/faraday/error.rb
mercadopago-custom-checkout-0.1.1 .gs/gems/faraday-0.9.2/lib/faraday/error.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/faraday-0.9.2/lib/faraday/error.rb
second_step-0.1.2 secondstep-notify-1.0.0-osx/lib/ruby/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/error.rb
tdiary-5.0.2 vendor/bundle/gems/faraday-0.9.2/lib/faraday/error.rb
tdiary-5.0.1 vendor/bundle/gems/faraday-0.9.2/lib/faraday/error.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/faraday-0.9.2/lib/faraday/error.rb
faraday-0.9.2 lib/faraday/error.rb
faraday-0.9.1 lib/faraday/error.rb
whos_dated_who-0.1.0 vendor/bundle/gems/faraday-0.9.0/lib/faraday/error.rb
whos_dated_who-0.0.1 vendor/bundle/gems/faraday-0.9.0/lib/faraday/error.rb
faraday-0.9.0 lib/faraday/error.rb
faraday-0.9.0.rc7 lib/faraday/error.rb