()
| 70 | |
| 71 | @contextmanager |
| 72 | def 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 | |
| 97 | class _UninitializedOperatorsDescriptor: |
no test coverage detected