Sha256: 8a87ca16a67b8dad78e8190929acf100ef8ada7f7228949501d78acc666cd0de

Contents?: true

Size: 627 Bytes

Versions: 4

Compression:

Stored size: 627 Bytes

Contents

require 'wayback/error'

module Wayback
  class Error
    # Raised when Wayback returns a 4xx HTTP status code or there's an error in Faraday
    class ClientError < Wayback::Error

      # Create a new error from an HTTP environment
      #
      # @param response [Hash]
      # @return [Wayback::Error]
      def self.from_response(response={})
        new(parse_error(response[:body]), response[:response_headers])
      end

    private

      def self.parse_error(body)
        if body.nil? || body.is_a?(String)
          ''
        # elsif body[:error]
        #   body[:error]
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wayback-0.3.1 lib/wayback/error/client_error.rb
wayback-0.2.1 lib/wayback/error/client_error.rb
wayback-0.2.0 lib/wayback/error/client_error.rb
wayback-0.1.0 lib/wayback/error/client_error.rb