scyph_extractors/
error.rs1use scyph_core::AppError;
4
5#[derive(Debug, thiserror::Error)]
11pub enum ExtractorError {
12 #[error("Invalid JSON body payload: {0}")]
14 JsonParse(String),
15
16 #[error("Invalid query parameters: {0}")]
18 QueryParse(String),
19
20 #[error("Invalid path parameter: {0}")]
22 PathParse(String),
23
24 #[error("Validation failed: {0}")]
26 Validation(String),
27}
28
29impl From<ExtractorError> for AppError {
30 fn from(err: ExtractorError) -> Self {
31 match err {
32 ExtractorError::JsonParse(msg) => AppError::BadRequest(msg),
33 ExtractorError::QueryParse(msg) => AppError::BadRequest(msg),
34 ExtractorError::PathParse(msg) => AppError::BadRequest(msg),
35 ExtractorError::Validation(msg) => AppError::UnprocessableEntity(msg),
36 }
37 }
38}