File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 2828
2929from google .rpc import error_details_pb2
3030
31+
32+ def _warn_could_not_import_grpcio_status ():
33+ warnings .warn (
34+ "Please install grpcio-status to obtain helpful grpc error messages." ,
35+ ImportWarning ,
36+ ) # pragma: NO COVER
37+
38+
3139try :
3240 import grpc
3341
3442 try :
3543 from grpc_status import rpc_status
3644 except ImportError : # pragma: NO COVER
37- warnings .warn (
38- "Please install grpcio-status to obtain helpful grpc error messages." ,
39- ImportWarning ,
40- )
45+ _warn_could_not_import_grpcio_status ()
4146 rpc_status = None
4247except ImportError : # pragma: NO COVER
4348 grpc = None
@@ -560,6 +565,9 @@ def _is_informative_grpc_error(rpc_exc):
560565
561566
562567def _parse_grpc_error_details (rpc_exc ):
568+ if not rpc_status : # pragma: NO COVER
569+ _warn_could_not_import_grpcio_status ()
570+ return [], None
563571 try :
564572 status = rpc_status .from_call (rpc_exc )
565573 except NotImplementedError : # workaround
You can’t perform that action at this time.
0 commit comments