class Toys::Settings::FieldError

Error raised when a value does not match the type constraint.

Attributes

field_name[R]

The field that rejected the value @return [Symbol]

settings_class[R]

The settings class that rejected the value @return [Class]

type_description[R]

A description of the type constraint, or nil if the field didn't exist. @return [String, nil]

value[R]

The value that did not match @return [Object]

Public Class Methods

new(value, settings_class, field_name, type_description) click to toggle source

@private

Calls superclass method
# File lib/toys/settings.rb, line 307
def initialize(value, settings_class, field_name, type_description)
  @value = value
  @settings_class = settings_class
  @field_name = field_name
  @type_description = type_description
  message = "unable to set #{settings_class}##{field_name}"
  message =
    if type_description
      "#{message}: value #{value.inspect} does not match type #{type_description}"
    else
      "#{message}: field does not exist"
    end
  super(message)
end