diff options
author | kennyj <kennyj@gmail.com> | 2013-03-01 01:55:20 +0900 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2013-03-20 10:11:07 +0000 |
commit | dc2bc388bc8c6c345337052bf0d60f5243d899d4 (patch) | |
tree | 3f4ec4d6873f1ab94af33fe37701d46e0a43f8cf /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | |
parent | be913c3964069fa9ff7c8a615e06705e3a6ec435 (diff) | |
download | rails-dc2bc388bc8c6c345337052bf0d60f5243d899d4.tar.gz rails-dc2bc388bc8c6c345337052bf0d60f5243d899d4.tar.bz2 rails-dc2bc388bc8c6c345337052bf0d60f5243d899d4.zip |
Wrong exception is occured when raising no translatable exception
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 2 |
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 f01dcec7be..cbbb195458 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -1144,6 +1144,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) |