File tree Expand file tree Collapse file tree 1 file changed +61
-0
lines changed
packages/postgres-database/src/simcore_postgres_database Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ """ aiopg errors
2+
3+ StandardError
4+ |__ Warning
5+ |__ Error
6+ |__ InterfaceError
7+ |__ DatabaseError
8+ |__ DataError
9+ |__ OperationalError
10+ |__ IntegrityError
11+ |__ InternalError
12+ |__ ProgrammingError
13+ |__ NotSupportedError
14+
15+ - aiopg reuses DBAPI exceptions
16+ SEE https://aiopg.readthedocs.io/en/stable/core.html?highlight=Exception#exceptions
17+ SEE http://initd.org/psycopg/docs/module.html#dbapi-exceptions
18+ """
19+ # NOTE: psycopg2.errors are created dynamically
20+ # pylint: disable=no-name-in-module
21+
22+ from typing import Tuple
23+
24+ from psycopg2 import DatabaseError , DataError
25+ from psycopg2 import Error as DBAPIError
26+ from psycopg2 import (
27+ IntegrityError ,
28+ InterfaceError ,
29+ InternalError ,
30+ NotSupportedError ,
31+ OperationalError ,
32+ ProgrammingError ,
33+ )
34+ from psycopg2 .errors import ForeignKeyViolation , NotNullViolation , UniqueViolation
35+
36+ assert issubclass (UniqueViolation , IntegrityError ) # nosec
37+
38+ # TODO: see https://stackoverflow.com/questions/58740043/how-do-i-catch-a-psycopg2-errors-uniqueviolation-error-in-a-python-flask-app
39+ # from sqlalchemy.exc import IntegrityError
40+ #
41+ # from psycopg2.errors import UniqueViolation
42+ #
43+ # try:
44+ # s.commit()
45+ # except IntegrityError as e:
46+ # assert isinstance(e.orig, UniqueViolation)
47+
48+
49+ __all__ : Tuple [str , ...] = (
50+ "DatabaseError" ,
51+ "DataError" ,
52+ "DBAPIError" ,
53+ "ForeignKeyViolation" ,
54+ "IntegrityError" ,
55+ "InterfaceError" ,
56+ "InternalError" ,
57+ "NotNullViolation" ,
58+ "NotSupportedError" ,
59+ "OperationalError" ,
60+ "ProgrammingError" ,
61+ )
You can’t perform that action at this time.
0 commit comments