2011-11-26 17:55:50 +00:00
|
|
|
module AASM
|
2015-03-02 04:08:45 +00:00
|
|
|
|
2015-08-05 10:00:22 +00:00
|
|
|
class UnknownStateMachineError < RuntimeError; end
|
|
|
|
|
2015-03-02 04:08:45 +00:00
|
|
|
class InvalidTransition < RuntimeError
|
2016-03-15 19:54:35 +00:00
|
|
|
attr_reader :object, :event_name, :originating_state, :failures
|
2015-05-13 10:12:59 +00:00
|
|
|
|
2015-10-22 02:38:07 +00:00
|
|
|
def initialize(object, event_name, state_machine_name, failures = [])
|
2016-03-15 19:54:35 +00:00
|
|
|
@object, @event_name, @originating_state, @failures = object, event_name, object.aasm(state_machine_name).current_state, failures
|
2017-04-10 14:53:18 +00:00
|
|
|
super("Event '#{event_name}' cannot transition from '#{originating_state}'. #{reasoning}")
|
2015-10-22 02:38:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def reasoning
|
2016-03-15 19:54:35 +00:00
|
|
|
"Failed callback(s): #{failures}." unless failures.empty?
|
2015-03-02 04:08:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-26 17:55:50 +00:00
|
|
|
class UndefinedState < RuntimeError; end
|
2014-05-18 12:21:35 +00:00
|
|
|
class NoDirectAssignmentError < RuntimeError; end
|
2011-11-26 17:55:50 +00:00
|
|
|
end
|