Skip to content

Commit 112049e

Browse files
authored
fix: allow grpc without grpcio-status (#355)
1 parent c89f55d commit 112049e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

google/api_core/exceptions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,23 @@
2424
import http.client
2525
from typing import Dict
2626
from typing import Union
27+
import warnings
2728

2829
from google.rpc import error_details_pb2
2930

3031
try:
3132
import grpc
32-
from grpc_status import rpc_status
33+
34+
try:
35+
from grpc_status import rpc_status
36+
except ImportError: # pragma: NO COVER
37+
warnings.warn(
38+
"Please install grpcio-status to obtain helpful grpc error messages.",
39+
ImportWarning,
40+
)
41+
rpc_status = None
3342
except ImportError: # pragma: NO COVER
3443
grpc = None
35-
rpc_status = None
3644

3745
# Lookup tables for mapping exceptions from HTTP and gRPC transports.
3846
# Populated by _GoogleAPICallErrorMeta

0 commit comments

Comments
 (0)