Exception: Fosm::GuardFailed

Inherits:
Error
  • Object
show all
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

Instance Method Summary collapse

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_nameObject (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_nameObject (readonly)

Returns the value of attribute guard_name.



21
22
23
# File 'lib/fosm/errors.rb', line 21

def guard_name
  @guard_name
end

#reasonObject (readonly)

Returns the value of attribute reason.



21
22
23
# File 'lib/fosm/errors.rb', line 21

def reason
  @reason
end