Sha256: 4b99560efe875a25e88c96b5cda9da0b19a92c95e2482b5d44eb40dc7cfb318a

Contents?: true

Size: 857 Bytes

Versions: 3

Compression:

Stored size: 857 Bytes

Contents

module JsonApiClient
  module Errors
    class ApiError < StandardError
      attr_reader :env
      def initialize(env)
        @env = env
      end
    end

    class ClientError < ApiError
    end

    class ServerError < ApiError
      attr_reader :uri
      def initialize(uri)
        @uri = uri
      end
      def message
        "Internal server error at: #{uri.to_s}"
      end
    end

    class NotFound < ServerError
      attr_reader :uri
      def initialize(uri)
        @uri = uri
      end
      def message
        "Couldn't find resource at: #{uri.to_s}"
      end
    end

    class UnexpectedStatus < ServerError
      attr_reader :code, :uri
      def initialize(code, uri)
        @code = code
        @uri = uri
      end
      def message
        "Unexpected response status: #{code} from: #{uri.to_s}"
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json_api_client-0.9.6 lib/json_api_client/errors.rb
json_api_client-0.9.5 lib/json_api_client/errors.rb
json_api_client-0.9.4 lib/json_api_client/errors.rb