diff options
Diffstat (limited to 'lib/errors.py')
-rw-r--r-- | lib/errors.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/errors.py b/lib/errors.py index dbf829b..492d5aa 100644 --- a/lib/errors.py +++ b/lib/errors.py @@ -10,6 +10,14 @@ from psycopg2._psycopg import ( QueryCanceledError, TransactionRollbackError) +def lookup(code): + """Lookup an error code and return its exception class. + + Raise `!KeyError` if the code is not found. + """ + return _by_sqlstate[code] + + _by_sqlstate = {} |