Skip to content

Commit

Permalink
Merge pull request #48879 from jhawthorn/get-rid-of-trilogy-errors-merge
Browse files Browse the repository at this point in the history
Get rid of trilogy errors merge
  • Loading branch information
jhawthorn committed Aug 4, 2023
2 parents 191ae49 + 08d58e7 commit 3cb00ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 117 deletions.

This file was deleted.

This file was deleted.

Expand Up @@ -6,8 +6,6 @@
require "trilogy"

require "active_record/connection_adapters/trilogy/database_statements"
require "active_record/connection_adapters/trilogy/lost_connection_exception_translator"
require "active_record/connection_adapters/trilogy/errors"

module ActiveRecord
module ConnectionHandling # :nodoc:
Expand Down Expand Up @@ -41,6 +39,7 @@ class TrilogyAdapter < AbstractMysqlAdapter
ER_BAD_DB_ERROR = 1049
ER_DBACCESS_DENIED_ERROR = 1044
ER_ACCESS_DENIED_ERROR = 1045
ER_SERVER_SHUTDOWN = 1053

ADAPTER_NAME = "Trilogy"

Expand Down Expand Up @@ -218,7 +217,21 @@ def translate_exception(exception, message:, sql:, binds:)
end
error_code = exception.error_code if exception.respond_to?(:error_code)

Trilogy::LostConnectionExceptionTranslator.new(exception, message, error_code, @pool).translate || super
case error_code
when ER_SERVER_SHUTDOWN
return ConnectionFailed.new(message, connection_pool: @pool)
end

case exception
when Errno::EPIPE, SocketError, IOError
return ConnectionFailed.new(message, connection_pool: @pool)
when ::Trilogy::Error
if /Connection reset by peer|TRILOGY_CLOSED_CONNECTION|TRILOGY_INVALID_SEQUENCE_ID|TRILOGY_UNEXPECTED_PACKET/.match?(exception.message)
return ConnectionFailed.new(message, connection_pool: @pool)
end
end

super
end

def default_prepared_statements
Expand Down

0 comments on commit 3cb00ed

Please sign in to comment.