Class: TTY::Link::ValueError

Inherits:
Error
  • Object
show all
Defined in:
lib/tty/link/errors.rb

Overview

Raised when a parameter value doesn’t match the allowed values

Instance Method Summary collapse

Constructor Details

#initialize(param_name, invalid_value, allowed_values) ⇒ ValueError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a TTY::Link::ValueError instance

Examples:

TTY::Link::ValueError.new(:name, :invalid, %i[valid_a valid_b])

Parameters:

  • param_name (Symbol)

    the parameter name

  • invalid_value (Object)

    the invalid value

  • allowed_values (Array)

    the allowed values



67
68
69
70
71
72
73
74
# File 'lib/tty/link/errors.rb', line 67

def initialize(param_name, invalid_value, allowed_values)
  super(format(
    MESSAGE,
    param_name: param_name.inspect,
    invalid_value: invalid_value.inspect,
    allowed_values: allowed_values.map(&:inspect).join(VALUES_SEPARATOR)
  ))
end