Sha256: ffc7d367e135c5ec1c6117383cc6a6695e64e256b13da1492504681a31ad0982

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module Loqate
  # Generic error returned from an API call
  class Error
    # 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:)
      @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

1 entries across 1 versions & 1 rubygems

Version Path
loqate-0.2.0 lib/loqate/error.rb