ApiError

Derive Macro ApiError 

Source
#[derive(ApiError)]
{
    // Attributes available to this derive:
    #[error]
}
Expand description

Derive macro for implementing IntoResponse for error enums

§Example

#[derive(ApiError)]
enum UserError {
    #[error(status = 404, message = "User not found")]
    NotFound(i64),
     
    #[error(status = 400, code = "validation_error")]
    InvalidInput(String),
}