From: Daniele Varrazzo Date: Tue, 17 Nov 2020 15:14:52 +0000 (+0000) Subject: Map errors 08* to OperationalError X-Git-Tag: 3.0.dev0~353 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ab576349d8e865782e2494084785050abf2185a;p=thirdparty%2Fpsycopg.git Map errors 08* to OperationalError See https://github.com/psycopg/psycopg2/pull/1148 --- diff --git a/psycopg3/psycopg3/errors.py b/psycopg3/psycopg3/errors.py index e59528df1..996c0d33a 100644 --- a/psycopg3/psycopg3/errors.py +++ b/psycopg3/psycopg3/errors.py @@ -266,6 +266,7 @@ def get_base_exception(sqlstate: str) -> Type[Error]: _base_exc_map = { + "08": OperationalError, # Connection Exception "0A": NotSupportedError, # Feature Not Supported "20": ProgrammingError, # Case Not Foud "21": ProgrammingError, # Cardinality Violation @@ -343,37 +344,37 @@ class SqlStatementNotYetComplete(DatabaseError): @sqlcode("08000") -class ConnectionException(DatabaseError): +class ConnectionException(OperationalError): pass @sqlcode("08001") -class SqlclientUnableToEstablishSqlconnection(DatabaseError): +class SqlclientUnableToEstablishSqlconnection(OperationalError): pass @sqlcode("08003") -class ConnectionDoesNotExist(DatabaseError): +class ConnectionDoesNotExist(OperationalError): pass @sqlcode("08004") -class SqlserverRejectedEstablishmentOfSqlconnection(DatabaseError): +class SqlserverRejectedEstablishmentOfSqlconnection(OperationalError): pass @sqlcode("08006") -class ConnectionFailure(DatabaseError): +class ConnectionFailure(OperationalError): pass @sqlcode("08007") -class TransactionResolutionUnknown(DatabaseError): +class TransactionResolutionUnknown(OperationalError): pass @sqlcode("08P01") -class ProtocolViolation(DatabaseError): +class ProtocolViolation(OperationalError): pass