use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use garde::Report;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum WithValidationRejection<T> {
    #[error(transparent)]
    ExtractionError(T),
    #[error(transparent)]
    ValidationError(#[from] Report),
}
impl<T: IntoResponse> IntoResponse for WithValidationRejection<T> {
    fn into_response(self) -> Response {
        match self {
            WithValidationRejection::ExtractionError(t) => t.into_response(),
            WithValidationRejection::ValidationError(e) => {
                (StatusCode::UNPROCESSABLE_ENTITY, format!("{e}")).into_response()
            }
        }
    }
}