pub mod corrector;
pub mod loss_functions;
pub mod problem;
pub mod residual_block;
pub mod variable;
use thiserror::Error;
use tracing::error;
#[derive(Debug, Clone, Error)]
pub enum CoreError {
#[error("Residual block error: {0}")]
ResidualBlock(String),
#[error("Variable error: {0}")]
Variable(String),
#[error("Factor linearization failed: {0}")]
FactorLinearization(String),
#[error("Symbolic structure error: {0}")]
SymbolicStructure(String),
#[error("Parallel computation error: {0}")]
ParallelComputation(String),
#[error("Dimension mismatch: {0}")]
DimensionMismatch(String),
#[error("Invalid constraint: {0}")]
InvalidConstraint(String),
#[error("Loss function error: {0}")]
LossFunction(String),
#[error("Invalid input: {0}")]
InvalidInput(String),
}
impl CoreError {
#[must_use]
pub fn log(self) -> Self {
error!("{}", self);
self
}
#[must_use]
pub fn log_with_source<E: std::fmt::Debug>(self, source_error: E) -> Self {
error!("{} | Source: {:?}", self, source_error);
self
}
}
pub type CoreResult<T> = Result<T, CoreError>;