File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 56
56
BlobLocationNotFoundException ,
57
57
DigestNotFoundException ,
58
58
ProgrammingError ,
59
+ IntegrityError ,
59
60
)
60
61
61
62
@@ -191,6 +192,18 @@ def _ex_to_message(ex):
191
192
192
193
193
194
def _raise_for_status (response ):
195
+ """
196
+ Properly raise `IntegrityError` exceptions for CrateDB's `DuplicateKeyException` errors.
197
+ """
198
+ try :
199
+ return _raise_for_status_real (response )
200
+ except ProgrammingError as ex :
201
+ if "DuplicateKeyException" in ex .message :
202
+ raise IntegrityError (ex .message , error_trace = ex .error_trace ) from ex
203
+ raise
204
+
205
+
206
+ def _raise_for_status_real (response ):
194
207
""" make sure that only crate.exceptions are raised that are defined in
195
208
the DB-API specification """
196
209
message = ''
You can’t perform that action at this time.
0 commit comments