#[derive(Debug, Clone, thiserror::Error)]
pub enum ProceduralError {
#[error("tokenize error: {detail}")]
Tokenize { detail: String },
#[error("parse error: {detail}")]
Parse { detail: String },
#[error("compile error: {detail}")]
Compile { detail: String },
#[error("validation error: {detail}")]
Validate { detail: String },
}
impl ProceduralError {
pub fn tokenize(detail: impl Into<String>) -> Self {
Self::Tokenize {
detail: detail.into(),
}
}
pub fn parse(detail: impl Into<String>) -> Self {
Self::Parse {
detail: detail.into(),
}
}
pub fn compile(detail: impl Into<String>) -> Self {
Self::Compile {
detail: detail.into(),
}
}
pub fn validate(detail: impl Into<String>) -> Self {
Self::Validate {
detail: detail.into(),
}
}
}
impl From<ProceduralError> for crate::Error {
fn from(e: ProceduralError) -> Self {
crate::Error::BadRequest {
detail: e.to_string(),
}
}
}