Skip to main content

Module error

Module error 

Source
Expand description

gRPC → HTTP error mapping.

Converts tonic::Status to appropriate HTTP status codes and JSON error bodies following the gRPC-HTTP status code mapping from the gRPC specification, and renders the typed google.rpc.Status details the upstream attached in the grpc-status-details-bin trailer.

Structs§

ErrorDetailsPolicy
Which routes return details in their error bodies.
StatusDetails
Renders the typed details of a gRPC status (grpc-status-details-bin) as proto3 JSON.

Functions§

error_body
The JSON error body for a failed call, shared by the unary response and the terminal frame of a stream so a client parses one shape everywhere.
grpc_to_http_status
Map a gRPC status code to the corresponding HTTP status code.
status_to_response
Convert a tonic::Status into an axum HTTP response with a JSON error body {"error", "message", "code"}, without status details.
status_to_response_with_details
Convert a tonic::Status into an axum HTTP response with a JSON error body.