Skip to main content

v2_error_envelope

Function v2_error_envelope 

Source
pub(crate) async fn v2_error_envelope(req: Request, next: Next) -> Response
Expand description

Give framework-level rejections on the v2 routes the same error envelope as handler errors.

The generated handlers extract with Query<T> or, on a POST, Json<T>, and axum answers a rejected query string or body itself, in text/plain, before tonic_rest::RestError is ever involved. protoJSON rejects unknown fields, which makes this the most common client error on these routes. Rebuilding the rejection as a [tonic::Status] reuses tonic-rest’s envelope.