From 6d6bcf8471b87c602093ab4061b49352e4efdd2b Mon Sep 17 00:00:00 2001 From: Egor Lynko Date: Mon, 10 Apr 2017 17:53:18 +0300 Subject: [PATCH] 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 --- lib/aasm/errors.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/aasm/errors.rb b/lib/aasm/errors.rb index f4ba67c..3fda3b9 100644 --- a/lib/aasm/errors.rb +++ b/lib/aasm/errors.rb @@ -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