axum-errors-extractor-rejections
axum-errors-extractor-rejections
Overview
Every Axum extractor that can fail carries an associated Rejection type. When
extraction fails, Axum does not bubble a Service error: it turns the
rejection straight into an HTTP response. Both extractor traits bound the
rejection with type Rejection: IntoResponse, which is the mechanism behind
Axum's infallible-handler model.
Built-in extractors ship predefined rejections in the axum::extract::rejection
module. The default rejection response is plain text with a sensible status
code. This skill covers the four ways to replace that default with your own
shape, and the Axum 0.8 change to Option<T> extractor behavior.
The rejection module and customization APIs are identical across Axum 0.7 and
0.8. The single version divergence is Option<T> extractor behavior (see the
decision tree below).