pub trait ApiError: Display {
// Required methods
fn status_code(&self) -> StatusCode;
fn error_code(&self) -> &'static str;
// Provided method
fn retry_after_secs(&self) -> Option<u64> { ... }
}Expand description
Trait for application-specific error types that can be rendered as structured JSON error responses.
Each project defines its own error enum and implements this trait.
The shared IntoResponse implementation (via into_error_response)
handles JSON serialization, status codes, and the Retry-After header
for rate-limited responses.
Required Methods§
Sourcefn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
HTTP status code for this error variant.
Sourcefn error_code(&self) -> &'static str
fn error_code(&self) -> &'static str
Machine-readable error code string (e.g. "INVALID_DOMAIN").
Provided Methods§
Sourcefn retry_after_secs(&self) -> Option<u64>
fn retry_after_secs(&self) -> Option<u64>
If this is a rate-limited error, return the retry-after duration in seconds.