#NEWLINE# def handler( context ) : #NEWLINE# #INDENT# 'Iterate through available filters and invoke those which match.\n\n    The first one which raises wins.   The order in which the filters\n    are attempted is sorted by specificity - dialect name or "*",\n    exception class per method resolution order (``__mro__``).\n    Method resolution order is used so that filter rules indicating a\n    more specific exception class are attempted first.\n\n    ' #NEWLINE# def _dialect_registries( engine ) : #NEWLINE# #INDENT# if ( engine . dialect . name in _registry ) : #NEWLINE# #INDENT# ( yield _registry [ engine . dialect . name ] ) #NEWLINE# #UNINDENT# if ( '*' in _registry ) : #NEWLINE# #INDENT# ( yield _registry [ '*' ] ) #NEWLINE# #UNINDENT# #UNINDENT# for per_dialect in _dialect_registries ( context . engine ) : #NEWLINE# #INDENT# for exc in ( context . sqlalchemy_exception , context . original_exception ) : #NEWLINE# #INDENT# for super_ in exc . __class__ . __mro__ : #NEWLINE# #INDENT# if ( super_ in per_dialect ) : #NEWLINE# #INDENT# regexp_reg = per_dialect [ super_ ] #NEWLINE# for ( fn , regexp ) in regexp_reg : #NEWLINE# #INDENT# match = regexp . match ( exc . args [ 0 ] ) #NEWLINE# if match : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# fn ( exc , match , context . engine . dialect . name , regexp_reg . is_disconnect ) #NEWLINE# #UNINDENT# except exception . DBConnectionError : #NEWLINE# #INDENT# context . is_disconnect = True #NEWLINE# raise