Sha256: 6eb1b1a5162fa5475781ddbd80698333cd4aeba02c58cd6b149301e4a0628b50

Contents?: true

Size: 661 Bytes

Versions: 3

Compression:

Stored size: 661 Bytes

Contents

require 'forwardable'

module Leadlight
  class Error < StandardError; end
  class CredentialsRequiredError < Error; end
  class HttpError < Error
    extend Forwardable

    attr_reader :request

    def_delegators :response, :status, :response

    def initialize(request, message=response.status.to_s)
      @request = request
      super(amplify_message(message))
    end

    private

    def amplify_message(message)
      "#{message} (#{request.http_method.upcase} #{request.location})"
    end
  end
  class ClientError < HttpError; end
  class ResourceNotFound < ClientError; end
  class ServerError < HttpError; end
  class TypeError < Error; end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
leadlight-0.1.0 lib/leadlight/errors.rb
leadlight-0.0.7 lib/leadlight/errors.rb
leadlight-0.0.6 lib/leadlight/errors.rb