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:
Egor Lynko 2017-04-10 17:53:18 +03:00 committed by Anil Kumar Maurya
parent 5fbdfff48b
commit 6d6bcf8471
1 changed files with 1 additions and 4 deletions

View File

@ -7,10 +7,7 @@ module AASM
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
end
def message
"Event '#{event_name}' cannot transition from '#{originating_state}'. #{reasoning}"
super("Event '#{event_name}' cannot transition from '#{originating_state}'. #{reasoning}")
end
def reasoning