Sha256: fdd14022061a5aec3828cebeebdf1bc0b98722bab293e16dca5ab29f523ed356

Contents?: true

Size: 957 Bytes

Versions: 13

Compression:

Stored size: 957 Bytes

Contents

module ActiveRecord
  class LostConnection < WrappedDatabaseException
  end

  class DeadlockVictim < WrappedDatabaseException
  end

  module ConnectionAdapters
    module Sqlserver
      module Errors
        LOST_CONNECTION_EXCEPTIONS  = {
          dblib: ['TinyTds::Error'],
          odbc: ['ODBC::Error']
        }.freeze

        LOST_CONNECTION_MESSAGES    = {
          dblib: [/closed connection/, /dead or not enabled/, /server failed/i],
          odbc: [/link failure/, /server failed/, /connection was already closed/, /invalid handle/i]
        }.freeze

        def lost_connection_exceptions
          exceptions = LOST_CONNECTION_EXCEPTIONS[@connection_options[:mode]]
          @lost_connection_exceptions ||= exceptions ? exceptions.map { |e| e.constantize rescue nil }.compact : []
        end

        def lost_connection_messages
          LOST_CONNECTION_MESSAGES[@connection_options[:mode]]
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
activerecord-sqlserver-adapter-4.1.8 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.0.4 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.1.7 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.0.3 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.1.6 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.0.2 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.1.5 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.1.4 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.0.1 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.1.2 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.1.1 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.1.0 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-4.0.0 lib/active_record/connection_adapters/sqlserver/errors.rb