Sha256: 29b2999b546e1e9899d3101acd7c25996f291d6622befeddb582b09a2524774b

Contents?: true

Size: 1.01 KB

Versions: 27

Compression:

Stored size: 1.01 KB

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

27 entries across 27 versions & 3 rubygems

Version Path
activerecord-sqlserver-adapter-3.2.18 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.17 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.16 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.15 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.14 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.13 lib/active_record/connection_adapters/sqlserver/errors.rb
sic-activerecord-sqlserver-adapter-4.0.0 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.12 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.11 lib/active_record/connection_adapters/sqlserver/errors.rb
asa-2000-1.0.0 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.10 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.9 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.8 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.7 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.6 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.5 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.4 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.3 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.2.2 lib/active_record/connection_adapters/sqlserver/errors.rb
activerecord-sqlserver-adapter-3.1.7 lib/active_record/connection_adapters/sqlserver/errors.rb