Sha256: e44b29933b04f1c8dde764361c06f3ca6b28fad5e591f49b5b12a2d6b60ecf21

Contents?: true

Size: 1.22 KB

Versions: 15

Compression:

Stored size: 1.22 KB

Contents

module Loqate
  # Generic error returned from an API call
  class Error < StandardError
    # Unique identifier for the error
    #
    # @return [Integer]
    #
    attr_reader :id

    # Descriptive information about the error
    #
    # @return [String]
    #
    attr_reader :description

    # What caused the error
    #
    # @return [String]
    #
    attr_reader :cause

    # How to solve the error
    #
    # @return [String]
    #
    attr_reader :resolution

    # Instantiates an error
    #
    # @param [Integer] id Unique identifier for the error
    # @param [String] description Descriptive information about the error
    # @param [String] cause What caused the error
    # @param [String] resolution How to solve the error
    #
    def initialize(id:, description:, cause:, resolution:)
      super(description)

      @id = id
      @cause = cause
      @resolution = resolution
      @description = description
    end

    # Compare the equality of this error with +other+. Two errors are considered equal if they have the same +id+.
    #
    # @param [Error] other Another error
    #
    # @return [Boolean]
    #
    # @api private
    #
    def ==(other)
      other.is_a?(Error) && id == other.id
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
loqate-0.12.0 lib/loqate/error.rb
loqate-0.11.1 lib/loqate/error.rb
loqate-0.11.0 lib/loqate/error.rb
loqate-0.10.4 lib/loqate/error.rb
loqate-0.10.3 lib/loqate/error.rb
loqate-0.10.2 lib/loqate/error.rb
loqate-0.10.1 lib/loqate/error.rb
loqate-0.10.0 lib/loqate/error.rb
loqate-0.9.0 lib/loqate/error.rb
loqate-0.8.0 lib/loqate/error.rb
loqate-0.7.0 lib/loqate/error.rb
loqate-0.6.0 lib/loqate/error.rb
loqate-0.5.0 lib/loqate/error.rb
loqate-0.4.0 lib/loqate/error.rb
loqate-0.3.0 lib/loqate/error.rb