Skip to content

Commit

Permalink
fix: Avoid AttributeError if grpcio-status is not installed (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddoskind committed Apr 26, 2022
1 parent 4497873 commit 022add1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion google/api_core/exceptions.py
Expand Up @@ -599,7 +599,9 @@ def from_grpc_error(rpc_exc):
"""
# NOTE(lidiz) All gRPC error shares the parent class grpc.RpcError.
# However, check for grpc.RpcError breaks backward compatibility.
if isinstance(rpc_exc, grpc.Call) or _is_informative_grpc_error(rpc_exc):
if (
grpc is not None and isinstance(rpc_exc, grpc.Call)
) or _is_informative_grpc_error(rpc_exc):
details, err_info = _parse_grpc_error_details(rpc_exc)
return from_grpc_status(
rpc_exc.code(),
Expand Down

0 comments on commit 022add1

Please sign in to comment.