From 02bcd71960c3ec6073d4ef2e9b5d208ceeaa61fe Mon Sep 17 00:00:00 2001 From: "v.promzelev" Date: Fri, 23 Sep 2016 15:52:34 +0400 Subject: initialize errors with name of class and other params --- activerecord/lib/active_record/relation/finder_methods.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 5e580ac865..97a819c5af 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -353,7 +353,7 @@ module ActiveRecord if ids.nil? error = "Couldn't find #{name}" error << " with#{conditions}" if conditions - raise RecordNotFound, error + raise RecordNotFound.new(error, name) elsif Array(ids).size == 1 error = "Couldn't find #{name} with '#{primary_key}'=#{ids}#{conditions}" raise RecordNotFound.new(error, name, primary_key, ids) @@ -361,7 +361,7 @@ module ActiveRecord error = "Couldn't find all #{name.pluralize} with '#{primary_key}': " error << "(#{ids.join(", ")})#{conditions} (found #{result_size} results, but was looking for #{expected_size})" - raise RecordNotFound, error + raise RecordNotFound.new(error, name, primary_key, ids) end end -- cgit v1.2.3