This repository was archived by the owner on Apr 1, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737class MutationsBatchError (Exception ):
3838 """Error in the batch request"""
3939
40- def __init__ (self , status_codes ):
41- self .errors = [
42- from_grpc_status (status_code .code , status_code .message )
43- for status_code in status_codes
44- if status_code .code != 0
45- ]
46- self .message = "Errors in batch mutations."
40+ def __init__ (self , message , exc ):
41+ self .exc = exc
42+ self .message = message
4743 super ().__init__ (self .message )
4844
4945
@@ -312,7 +308,12 @@ def flush_rows(self, rows_to_flush=None):
312308 responses .append (result )
313309
314310 if has_error :
315- raise MutationsBatchError (status_codes = responses )
311+ exc = [
312+ from_grpc_status (status_code .code , status_code .message )
313+ for status_code in responses
314+ if status_code .code != 0
315+ ]
316+ raise MutationsBatchError (message = "Errors in batch mutations." , exc = exc )
316317
317318 return responses
318319
Original file line number Diff line number Diff line change @@ -243,10 +243,10 @@ def test_mutations_batcher_response_with_error_codes():
243243 with pytest .raises (MutationsBatchError ) as exc :
244244 mutation_batcher .flush ()
245245 assert exc .value .message == "Errors in batch mutations."
246- assert len (exc .value .errors ) == 2
246+ assert len (exc .value .exc ) == 2
247247
248- assert exc .value .errors [0 ].message == mocked_response [0 ].message
249- assert exc .value .errors [1 ].message == mocked_response [1 ].message
248+ assert exc .value .exc [0 ].message == mocked_response [0 ].message
249+ assert exc .value .exc [1 ].message == mocked_response [1 ].message
250250
251251
252252def test_mutations_batcher_flush_async_raises_exception ():
@@ -266,10 +266,10 @@ def test_mutations_batcher_flush_async_raises_exception():
266266 with pytest .raises (MutationsBatchError ) as exc :
267267 mutation_batcher .flush_async ()
268268 assert exc .value .message == "Errors in batch mutations."
269- assert len (exc .value .errors ) == 2
269+ assert len (exc .value .exc ) == 2
270270
271- assert exc .value .errors [0 ].message == mocked_response [0 ].message
272- assert exc .value .errors [1 ].message == mocked_response [1 ].message
271+ assert exc .value .exc [0 ].message == mocked_response [0 ].message
272+ assert exc .value .exc [1 ].message == mocked_response [1 ].message
273273
274274
275275class _Instance (object ):
You can’t perform that action at this time.
0 commit comments