use logit_loom_core::{CallbackFailure, CoreError};
use thiserror::Error;
#[derive(Clone, Debug, PartialEq, Eq, Error)]
#[error("{message}")]
pub struct TransformError {
message: String,
}
impl TransformError {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Error)]
#[error("{message}")]
pub struct ObserverError {
message: String,
}
impl ObserverError {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Error)]
#[error("{message}")]
pub struct PrefillObserverError {
message: String,
}
impl PrefillObserverError {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum PipelineError {
#[error(transparent)]
Contract(#[from] CoreError),
#[error("pipeline has not begun")]
NotBegun,
#[error("pipeline is failed; call begin before reuse")]
Failed,
#[error("invalid transform step {actual}; expected {expected}")]
InvalidStep {
expected: u32,
actual: u32,
},
#[error("token admission has no unmatched successful transform invocation")]
UnexpectedAdmission,
#[error("previous transform invocation is still awaiting causal admission")]
AdmissionPending,
#[error("invalid candidate view: {0}")]
InvalidCandidates(String),
#[error("pipeline accounting overflowed: {0}")]
AccountingOverflow(&'static str),
#[error("transform stage {stage} failed: {failure:?}")]
Callback {
stage: usize,
failure: CallbackFailure,
},
}