fix: allow grpc without grpcio-status (#355)
diff --git a/google/api_core/exceptions.py b/google/api_core/exceptions.py
index 24b65ee..38fe6e7 100644
--- a/google/api_core/exceptions.py
+++ b/google/api_core/exceptions.py
@@ -24,15 +24,23 @@
import http.client
from typing import Dict
from typing import Union
+import warnings
from google.rpc import error_details_pb2
try:
import grpc
- from grpc_status import rpc_status
+
+ try:
+ from grpc_status import rpc_status
+ except ImportError: # pragma: NO COVER
+ warnings.warn(
+ "Please install grpcio-status to obtain helpful grpc error messages.",
+ ImportWarning,
+ )
+ rpc_status = None
except ImportError: # pragma: NO COVER
grpc = None
- rpc_status = None
# Lookup tables for mapping exceptions from HTTP and gRPC transports.
# Populated by _GoogleAPICallErrorMeta