intrepid_core/extract/
extractor_error.rs1use std::convert::Infallible;
2
3use crate::{PathError, StateNotReadyError};
4
5#[derive(Debug, thiserror::Error)]
7#[error("Frame is not a message")]
8pub struct WrongFrameError;
9
10#[derive(Debug, thiserror::Error)]
12#[error("Frame has wrong meta content: {0}")]
13pub struct MetaMismatchError(pub String);
14
15#[derive(Debug, thiserror::Error)]
17pub enum MessageFrameError {
18 #[error(transparent)]
20 WrongFrame(#[from] WrongFrameError),
21
22 #[error(transparent)]
24 MetaMismatch(#[from] MetaMismatchError),
25
26 #[error("malformed data field: {0}")]
28 MalformedJsonData(#[source] serde_json::Error),
29 #[error("malformed meta field: {0}")]
31 MalformedJsonMeta(#[source] serde_json::Error),
32}
33
34#[derive(Debug, thiserror::Error)]
36pub enum ExtractorError {
37 #[error(transparent)]
39 MessageFrameError(#[from] MessageFrameError),
40 #[error("Path routing failed in extraction: {0}")]
42 RoutingFailed(#[from] PathError),
43 #[error(transparent)]
45 StateNotReady(#[from] StateNotReadyError),
46 #[error(transparent)]
48 Boxed(#[from] tower::BoxError),
49 #[error("extracting failed: {0}")]
51 ExtractionFailed(String),
52}
53
54impl From<String> for ExtractorError {
55 fn from(error: String) -> Self {
56 Self::ExtractionFailed(error)
57 }
58}
59
60impl From<Infallible> for ExtractorError {
61 fn from(_: Infallible) -> Self {
62 unreachable!("Infallible error thrown in extractor")
63 }
64}