lib/state_machine/transition.rb in state_machine-1.0.3 vs lib/state_machine/transition.rb in state_machine-1.1.0

- old
+ new

@@ -13,12 +13,15 @@ def initialize(object, machine, event) #:nodoc: @machine = machine @from_state = machine.states.match!(object) @from = machine.read(object, :state) @event = machine.events.fetch(event) + errors = machine.errors_for(object) - super(object, "Cannot transition #{machine.name} via :#{self.event} from #{from_name.inspect}") + message = "Cannot transition #{machine.name} via :#{self.event} from #{from_name.inspect}" + message << " (Reason(s): #{errors})" unless errors.empty? + super(object, message) end # The event that triggered the failed transition def event @event.name @@ -349,9 +352,11 @@ # Pauses the current callback execution. This should only occur within # around callbacks when the remainder of the callback will be executed at # a later point in time. def pause + raise ArgumentError, 'around_transition callbacks cannot be called in multiple execution contexts in java implementations of Ruby. Use before/after_transitions instead.' if RUBY_PLATFORM == 'java' + unless @resume_block require 'continuation' unless defined?(callcc) callcc do |block| @paused_block = block throw :halt, true