Exception: LocoMotion::InvalidModifierError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/loco_motion/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(modifier, component, custom_message = nil) ⇒ InvalidModifierError

Returns a new instance of InvalidModifierError.



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/loco_motion/errors.rb', line 21

def initialize(modifier, component, custom_message = nil)
  no_modifiers_explanation = "No modifiers are defined on the component."
  default_explanation = "Valid modifiers are #{component.valid_modifiers.map(&:inspect).to_sentence}."

  has_modifiers = component.valid_modifiers.present?

  default_message = [
    "Unknown modifier #{modifier.inspect}.",
    (has_modifiers ? default_explanation : no_modifiers_explanation).to_s
  ].join(" ")

  super(custom_message || default_message)
end