Sha256: 7fda454e1494199fef8f7ec1e87caca967c6f0656ee411335317adbeb314f7cb

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

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

    class ClientError < ApiError
    end

    class AccessDenied < ClientError
    end

    class NotAuthorized < ClientError
    end

    class ConnectionError < ApiError
    end

    class ServerError < ApiError
      def initialize(env, msg = 'Internal server error')
        super env, msg
      end
    end

    class Conflict < ServerError
      def initialize(env, msg = 'Resource already exists')
        super env, msg
      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

4 entries across 4 versions & 1 rubygems

Version Path
json_api_client-1.11.0 lib/json_api_client/errors.rb
json_api_client-1.10.0 lib/json_api_client/errors.rb
json_api_client-1.9.0 lib/json_api_client/errors.rb
json_api_client-1.8.0 lib/json_api_client/errors.rb