Sha256: 8a149de547335da1ed55b6560e9f7f86a98ae8ce61a2e80d8ff0620bf6430551

Contents?: true

Size: 1021 Bytes

Versions: 4

Compression:

Stored size: 1021 Bytes

Contents

module Faraday
  module Error
    class ClientError < StandardError
      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 MissingDependency < StandardError; end

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
faraday-0.8.11 lib/faraday/error.rb
faraday-0.8.10 lib/faraday/error.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/faraday-0.8.9/lib/faraday/error.rb
faraday-0.8.9 lib/faraday/error.rb