diff options
author | Kir Shatrov <shatrov@me.com> | 2019-07-16 20:08:50 +0100 |
---|---|---|
committer | Kir Shatrov <shatrov@me.com> | 2019-07-16 20:24:27 +0100 |
commit | 080939c98724b039704ca8115ba610134d1edcff (patch) | |
tree | c47ca5efeac488817c5074ad95c6310c5b3ee2c9 /activerecord/lib | |
parent | da4e18c5c2e965bfdfc442b92881326453de6f80 (diff) | |
download | rails-080939c98724b039704ca8115ba610134d1edcff.tar.gz rails-080939c98724b039704ca8115ba610134d1edcff.tar.bz2 rails-080939c98724b039704ca8115ba610134d1edcff.zip |
Raise specific exception on Mysql2::Error::TimeoutError
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/errors.rb | 4 |
2 files changed, 9 insertions, 1 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 e9ae8d159e..405fecb603 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -619,7 +619,11 @@ module ActiveRecord when ER_QUERY_INTERRUPTED QueryCanceled.new(message, sql: sql, binds: binds) else - super + if exception.is_a?(Mysql2::Error::TimeoutError) + ActiveRecord::AdapterTimeout.new(message, sql: sql, binds: binds) + else + super + end end end diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index c8c06375a3..012ff8c46f 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -365,6 +365,10 @@ module ActiveRecord class QueryCanceled < StatementInvalid end + # AdapterTimeout will be raised when database clients times out while waiting from the server + class AdapterTimeout < StatementInvalid + end + # UnknownAttributeReference is raised when an unknown and potentially unsafe # value is passed to a query method when allow_unsafe_raw_sql is set to # :disabled. For example, passing a non column name value to a relation's |