Exception: LocoMotion::UnknownPartError
- Inherits:
-
StandardError
- Object
- StandardError
- LocoMotion::UnknownPartError
- Defined in:
- lib/loco_motion/errors.rb
Overview
Raised when a component is asked to operate on a part (e.g. via BaseComponent#part, ComponentConfig#get_part, or ComponentConfig#validate_part) that isn't declared on that component.
Instance Method Summary collapse
-
#initialize(part, component, custom_message = nil) ⇒ UnknownPartError
constructor
A new instance of UnknownPartError.
Constructor Details
#initialize(part, component, custom_message = nil) ⇒ UnknownPartError
Returns a new instance of UnknownPartError.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/loco_motion/errors.rb', line 20 def initialize(part, component, = nil) no_parts_explanation = "No parts are defined on the component." default_explanation = "Valid parts are #{component.config.valid_parts.map(&:inspect).to_sentence}." has_parts = component.config.valid_parts.present? = [ "Unknown part #{part.inspect}.", (has_parts ? default_explanation : no_parts_explanation).to_s ].join(" ") super( || ) end |