Exception: Fosm::GuardFailed
- Defined in:
- lib/fosm/errors.rb
Overview
Raised when a guard blocks a transition 🆕 Supports optional reason for better error messages
Instance Attribute Summary collapse
-
#event_name ⇒ Object
readonly
Returns the value of attribute event_name.
-
#guard_name ⇒ Object
readonly
Returns the value of attribute guard_name.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Instance Method Summary collapse
-
#initialize(guard_name, event_name, reason = nil) ⇒ GuardFailed
constructor
A new instance of GuardFailed.
Constructor Details
#initialize(guard_name, event_name, reason = nil) ⇒ GuardFailed
Returns a new instance of GuardFailed.
23 24 25 26 27 28 29 30 |
# File 'lib/fosm/errors.rb', line 23 def initialize(guard_name, event_name, reason = nil) @guard_name = guard_name @event_name = event_name @reason = reason msg = "Guard '#{guard_name}' prevented transition for event '#{event_name}'" msg += ": #{reason}" if reason super(msg) end |
Instance Attribute Details
#event_name ⇒ Object (readonly)
Returns the value of attribute event_name.
21 22 23 |
# File 'lib/fosm/errors.rb', line 21 def event_name @event_name end |
#guard_name ⇒ Object (readonly)
Returns the value of attribute guard_name.
21 22 23 |
# File 'lib/fosm/errors.rb', line 21 def guard_name @guard_name end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
21 22 23 |
# File 'lib/fosm/errors.rb', line 21 def reason @reason end |