aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorkennyj <kennyj@gmail.com>2013-03-01 01:55:20 +0900
committerkennyj <kennyj@gmail.com>2013-03-01 02:47:57 +0900
commite2a4b7a506e36839771284942829cbbe8d40b377 (patch)
tree7401e84147410032910b6669e7e4bc9484af53d2 /activerecord/lib
parent8f6b70f1fd49b8520a744cc90102051043faf315 (diff)
downloadrails-e2a4b7a506e36839771284942829cbbe8d40b377.tar.gz
rails-e2a4b7a506e36839771284942829cbbe8d40b377.tar.bz2
rails-e2a4b7a506e36839771284942829cbbe8d40b377.zip
Wrong exception is occured when raising no translatable exception
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index b39eb058ae..c91e1b3fb9 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -675,6 +675,8 @@ module ActiveRecord
UNIQUE_VIOLATION = "23505"
def translate_exception(exception, message)
+ return exception unless exception.respond_to?(:result)
+
case exception.result.try(:error_field, PGresult::PG_DIAG_SQLSTATE)
when UNIQUE_VIOLATION
RecordNotUnique.new(message, exception)