Sha256: 7aeb3834501ac59f705c4b509a29cabe8deaa4cadcc596954cc9207197889073

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

# frozen_string_literal: true

class Valvat
  Error = Class.new(RuntimeError)

  class LookupError < Error
    def initialize(message, kind)
      @message = message.to_s
      @kind = kind.is_a?(Class) ? kind.name.split('::').last : kind.to_s
      super(@message)
    end

    def to_s
      "The #{@kind} web service returned the error: #{@message}"
    end

    def eql?(other)
      to_s.eql?(other.to_s)
    end
  end
  MaintenanceError = Class.new(LookupError)

  ServiceUnavailable = Class.new(MaintenanceError)
  MemberStateUnavailable = Class.new(MaintenanceError)

  Timeout = Class.new(LookupError)
  InvalidRequester = Class.new(LookupError)
  BlockedError = Class.new(LookupError)
  RateLimitError = Class.new(LookupError)

  UnknownLookupError = Class.new(LookupError)

  HTTPError = Class.new(LookupError)

  AuthorizationError = Class.new(LookupError)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
valvat-2.0.1 lib/valvat/error.rb
valvat-2.0.0 lib/valvat/error.rb