File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 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):
487487
488488
489489def _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+
491495 if not status :
492496 return []
497+
493498 possible_errors = [
494499 error_details_pb2 .BadRequest ,
495500 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():
237237 assert exception .response == error
238238
239239
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+
240268def create_bad_request_details ():
241269 bad_request_details = error_details_pb2 .BadRequest ()
242270 field_violation = bad_request_details .field_violations .add ()
You can’t perform that action at this time.
0 commit comments