aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorErol Fornoles <erol.fornoles@gmail.com>2016-05-22 14:11:06 +0800
committerErol Fornoles <erol.fornoles@gmail.com>2016-05-24 19:04:38 +0800
commitf5c0c7ffa09c3e29a6ba361d927f6c45f49d6425 (patch)
tree268f424de894fb899ab4b428b9757c4fbc0c90d6 /activerecord/lib/active_record/connection_adapters
parent61483b18bcbfaa054113a67f40515c7bf3e892b2 (diff)
downloadrails-f5c0c7ffa09c3e29a6ba361d927f6c45f49d6425.tar.gz
rails-f5c0c7ffa09c3e29a6ba361d927f6c45f49d6425.tar.bz2
rails-f5c0c7ffa09c3e29a6ba361d927f6c45f49d6425.zip
Introduce new ActiveRecord transaction error classes
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb5
2 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
index 44b4b547f3..17aa4000c7 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -742,7 +742,7 @@ module ActiveRecord
when ER_DATA_TOO_LONG
ValueTooLong.new(message)
when ER_LOCK_DEADLOCK
- TransactionSerializationError.new(message)
+ DeadlockDetected.new(message)
else
super
end
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index ddfc560747..c9d436e19f 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -407,6 +407,7 @@ module ActiveRecord
FOREIGN_KEY_VIOLATION = "23503"
UNIQUE_VIOLATION = "23505"
SERIALIZATION_FAILURE = "40001"
+ DEADLOCK_DETECTED = "40P01"
def translate_exception(exception, message)
return exception unless exception.respond_to?(:result)
@@ -419,7 +420,9 @@ module ActiveRecord
when VALUE_LIMIT_VIOLATION
ValueTooLong.new(message)
when SERIALIZATION_FAILURE
- TransactionSerializationError.new(message)
+ SerializationFailure.new(message)
+ when DEADLOCK_DETECTED
+ DeadlockDetected.new(message)
else
super
end