MCPcopy
hub / github.com/django/django / wrap_oracle_errors

Function wrap_oracle_errors

django/db/backends/oracle/base.py:72–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70
71@contextmanager
72def wrap_oracle_errors():
73 try:
74 yield
75 except Database.DatabaseError as e:
76 # oracledb raises a oracledb.DatabaseError exception with the
77 # following attributes and values:
78 # code = 2091
79 # message = 'ORA-02091: transaction rolled back
80 # 'ORA-02291: integrity constraint (TEST_DJANGOTEST.SYS
81 # _C00102056) violated - parent key not found'
82 # or:
83 # 'ORA-00001: unique constraint (DJANGOTEST.DEFERRABLE_
84 # PINK_CONSTRAINT) violated
85 # Convert that case to Django's IntegrityError exception.
86 x = e.args[0]
87 if (
88 hasattr(x, "code")
89 and hasattr(x, "message")
90 and x.code == 2091
91 and ("ORA-02291" in x.message or "ORA-00001" in x.message)
92 ):
93 raise IntegrityError(*tuple(e.args))
94 raise
95
96
97class _UninitializedOperatorsDescriptor:

Callers 3

_commitMethod · 0.85
executeMethod · 0.85
executemanyMethod · 0.85

Calls 1

IntegrityErrorClass · 0.90

Tested by

no test coverage detected