intrepid_core/extract/
extractor_error.rsuse std::convert::Infallible;
use crate::{PathError, StateNotReadyError};
#[derive(Debug, thiserror::Error)]
#[error("Frame is not a message")]
pub struct WrongFrameError;
#[derive(Debug, thiserror::Error)]
pub enum MessageFrameError {
#[error(transparent)]
WrongFrame(#[from] WrongFrameError),
#[error("malformed data field: {0}")]
MalformedJsonData(#[source] serde_json::Error),
#[error("malformed meta field: {0}")]
MalformedJsonMeta(#[source] serde_json::Error),
}
#[derive(Debug, thiserror::Error)]
pub enum ExtractorError {
#[error(transparent)]
MessageFrameError(#[from] MessageFrameError),
#[error("Path routing failed in extraction: {0}")]
RoutingFailed(#[from] PathError),
#[error(transparent)]
StateNotReady(#[from] StateNotReadyError),
#[error(transparent)]
Boxed(#[from] tower::BoxError),
#[error("extracting failed: {0}")]
ExtractionFailed(String),
}
impl From<String> for ExtractorError {
fn from(error: String) -> Self {
Self::ExtractionFailed(error)
}
}
impl From<Infallible> for ExtractorError {
fn from(_: Infallible) -> Self {
unreachable!("Infallible error thrown in extractor")
}
}