File tree 2 files changed +34
-1
lines changed
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -487,9 +487,14 @@ def _is_informative_grpc_error(rpc_exc):
487
487
488
488
489
489
def _parse_grpc_error_details (rpc_exc ):
490
- status = rpc_status .from_call (rpc_exc )
490
+ try :
491
+ status = rpc_status .from_call (rpc_exc )
492
+ except NotImplementedError : # workaround
493
+ return []
494
+
491
495
if not status :
492
496
return []
497
+
493
498
possible_errors = [
494
499
error_details_pb2 .BadRequest ,
495
500
error_details_pb2 .PreconditionFailure ,
Original file line number Diff line number Diff line change @@ -237,6 +237,34 @@ def test_from_grpc_error_non_call():
237
237
assert exception .response == error
238
238
239
239
240
+ @pytest .mark .skipif (grpc is None , reason = "No grpc" )
241
+ def test_from_grpc_error_bare_call ():
242
+ message = "Testing"
243
+
244
+ class TestingError (grpc .Call , grpc .RpcError ):
245
+ def __init__ (self , exception ):
246
+ self .exception = exception
247
+
248
+ def code (self ):
249
+ return self .exception .grpc_status_code
250
+
251
+ def details (self ):
252
+ return message
253
+
254
+ nested_message = "message"
255
+ error = TestingError (exceptions .GoogleAPICallError (nested_message ))
256
+
257
+ exception = exceptions .from_grpc_error (error )
258
+
259
+ assert isinstance (exception , exceptions .GoogleAPICallError )
260
+ assert exception .code is None
261
+ assert exception .grpc_status_code is None
262
+ assert exception .message == message
263
+ assert exception .errors == [error ]
264
+ assert exception .response == error
265
+ assert exception .details == []
266
+
267
+
240
268
def create_bad_request_details ():
241
269
bad_request_details = error_details_pb2 .BadRequest ()
242
270
field_violation = bad_request_details .field_violations .add ()
You can’t perform that action at this time.
0 commit comments