From 1543863548bcd7515fac7b7b1931b6e23fedf80f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 14 Jan 2014 17:58:17 -0800 Subject: fix exception translation --- .../lib/active_record/connection_adapters/abstract_adapter.rb | 5 +++-- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index d1acef3e53..3c94bad208 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -349,11 +349,12 @@ module ActiveRecord protected - def translate_exception(e, sql) + def translate_exception_class(e, sql) message = "#{e.class.name}: #{e.message}: #{sql}" @logger.error message if @logger exception = translate_exception(e, message) exception.set_backtrace e.backtrace + exception end def log(sql, name = "SQL", binds = [], statement_name = nil) @@ -365,7 +366,7 @@ module ActiveRecord :statement_name => statement_name, :binds => binds) { yield } rescue => e - raise translate_exception(e, sql) + raise translate_exception_class(e, sql) end def translate_exception(exception, message) diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index ebbe918442..a471383041 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -856,7 +856,7 @@ module ActiveRecord begin @connection.prepare nextkey, sql rescue => e - raise translate_exception(e, sql) + raise translate_exception_class(e, sql) end # Clear the queue @connection.get_last_result -- cgit v1.2.3