Exception: Horologium::UnknownPrecisionError

Inherits:
Error
  • Object
show all
Defined in:
lib/horologium/error.rb,
sig/horologium.rbs

Overview

Raised when a precision the library does not recognise is given, to the configuration or when building a value. It carries the known precisions so the caller can see the valid choices.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(precision, known_precisions) ⇒ UnknownPrecisionError

Returns a new instance of UnknownPrecisionError.

Parameters:

  • precision (Object)

    the unknown precision that was given

  • known_precisions (Array<Symbol>)

    the recognised precisions



29
30
31
32
33
34
35
# File 'lib/horologium/error.rb', line 29

def initialize(precision, known_precisions)
  @known_precisions = known_precisions.dup.freeze
  super(
    "unknown precision #{precision.inspect}, " \
    "expected one of #{known_precisions.map(&:inspect).join(", ")}"
  )
end

Instance Attribute Details

#known_precisionsArray<Symbol> (readonly)

The precisions the library recognises.

Returns:

  • (Array<Symbol>)


25
26
27
# File 'lib/horologium/error.rb', line 25

def known_precisions
  @known_precisions
end