Skip to content

Commit 022add1

Browse files
authored
fix: Avoid AttributeError if grpcio-status is not installed (#370)
1 parent 4497873 commit 022add1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

google/api_core/exceptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,9 @@ def from_grpc_error(rpc_exc):
599599
"""
600600
# NOTE(lidiz) All gRPC error shares the parent class grpc.RpcError.
601601
# However, check for grpc.RpcError breaks backward compatibility.
602-
if isinstance(rpc_exc, grpc.Call) or _is_informative_grpc_error(rpc_exc):
602+
if (
603+
grpc is not None and isinstance(rpc_exc, grpc.Call)
604+
) or _is_informative_grpc_error(rpc_exc):
603605
details, err_info = _parse_grpc_error_details(rpc_exc)
604606
return from_grpc_status(
605607
rpc_exc.code(),

0 commit comments

Comments
 (0)