Make errors more inspectable by settings message
When message is set as variable, instead of redefining `message` method, the message will be used in `inspect` and `to_s` calls, both implicit and explicit, which improves logs readability and simmplifies debugging in the irb
This commit is contained in:
parent
5fbdfff48b
commit
6d6bcf8471
|
@ -7,10 +7,7 @@ module AASM
|
||||||
|
|
||||||
def initialize(object, event_name, state_machine_name, failures = [])
|
def initialize(object, event_name, state_machine_name, failures = [])
|
||||||
@object, @event_name, @originating_state, @failures = object, event_name, object.aasm(state_machine_name).current_state, failures
|
@object, @event_name, @originating_state, @failures = object, event_name, object.aasm(state_machine_name).current_state, failures
|
||||||
end
|
super("Event '#{event_name}' cannot transition from '#{originating_state}'. #{reasoning}")
|
||||||
|
|
||||||
def message
|
|
||||||
"Event '#{event_name}' cannot transition from '#{originating_state}'. #{reasoning}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def reasoning
|
def reasoning
|
||||||
|
|
Loading…
Reference in New Issue