use crate::response::Response;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ExtractQueryParamsError {
#[error(transparent)]
QueryDeserializationError(QueryDeserializationError),
}
impl ExtractQueryParamsError {
pub fn into_response(&self) -> Response {
match self {
Self::QueryDeserializationError(e) => Response::bad_request()
.set_typed_body(format!("Invalid query parameters.\n{:?}", e)),
}
}
}
#[derive(Debug, thiserror::Error)]
#[error(transparent)]
pub struct QueryDeserializationError {
inner: serde_path_to_error::Error<serde_html_form::de::Error>,
}
impl QueryDeserializationError {
pub(super) fn new(e: serde_path_to_error::Error<serde_html_form::de::Error>) -> Self {
Self { inner: e }
}
}