module documentation

Helpers for converting service-level protobuf errors into SDK types.

This module builds on request_status to represent detailed service errors (ServiceError PBs) and to decide retriability based on service semantics and gRPC status codes.

Class RequestStatusExtended Extended request status that includes parsed service errors.
Exception RequestError Exception raised for requests that failed with service-level errors.
Function int_to_status_code Convert an integer or StatusCode into a StatusCode instance.
Function is_dns_error Return True when an exception indicates a DNS resolution problem.
Function is_network_error Return True for network errors that look like timeouts.
Function is_retriable_error Decide whether an exception should be retried.
Function is_transport_error Return True for transport-level errors such as connection reset.
Function to_anypb Pack a ServiceError protobuf into a google.protobuf.Any message.
Function to_str Render a ServiceError into a concise human readable string.
Variable code_map Undocumented
Variable DefaultRetriableCodes Undocumented
def int_to_status_code(i: int | StatusCode) -> StatusCode: (source)

Convert an integer or StatusCode into a StatusCode instance.

Useful when reading numeric status codes from protobuf messages.

def is_dns_error(err: Exception) -> bool: (source)

Return True when an exception indicates a DNS resolution problem.

def is_network_error(err: Exception) -> bool: (source)

Return True for network errors that look like timeouts.

def is_retriable_error(err: Exception, deadline_retriable: bool = False) -> bool: (source)

Decide whether an exception should be retried.

The function recognizes RequestError (service-level errors) and also checks for common network/transport error conditions.

def is_transport_error(err: Exception) -> bool: (source)

Return True for transport-level errors such as connection reset.

This is a heuristic based on the textual content of the exception.

def to_anypb(err: ServiceError) -> AnyPb: (source)

Pack a ServiceError protobuf into a google.protobuf.Any message.

This helper is used when converting SDK-level error representations back into gRPC status details.

def to_str(err: ServiceError) -> str: (source)

Render a ServiceError into a concise human readable string.

The function inspects typed details attached to the service error and produces a one-line summary intended for logs and exception messages.

code_map = (source)

Undocumented

DefaultRetriableCodes = (source)

Undocumented