Skip to main content

IsGrpcErrorWithCode

Checks if the given error is a gRPC error with a specific status code.

def IsGrpcErrorWithCode(
code: codes.Code,
err: error
) - > bool

Checks if a given error is a gRPC error with a specific status code. This function is useful for handling gRPC errors by allowing callers to determine if an error matches an expected gRPC status code.

Parameters​

NameTypeDescription
codecodes.CodeThe gRPC status code to check against the error.
errerrorThe error object to inspect.

Returns​

TypeDescription
boolTrue if the error is a gRPC error and its status code matches the provided code, False otherwise.