nereids_pipeline/
error.rs

1//! Error types for the nereids-pipeline crate.
2
3use nereids_fitting::error::FittingError;
4use nereids_physics::transmission::TransmissionError;
5
6/// Errors that can occur during pipeline operations.
7#[derive(Debug, thiserror::Error)]
8pub enum PipelineError {
9    /// Array shape or length mismatch between inputs.
10    #[error("Shape mismatch: {0}")]
11    ShapeMismatch(String),
12
13    /// Invalid parameter value.
14    #[error("Invalid parameter: {0}")]
15    InvalidParameter(String),
16
17    /// Operation was cancelled via the cancellation token.
18    #[error("Operation cancelled")]
19    Cancelled,
20
21    /// Error from the transmission forward model (e.g. unsorted energy grid).
22    #[error("Transmission error: {0}")]
23    Transmission(TransmissionError),
24
25    /// Error from the fitting engine (e.g. empty data, length mismatch).
26    #[error("Fitting error: {0}")]
27    Fitting(FittingError),
28}
29
30impl From<TransmissionError> for PipelineError {
31    fn from(e: TransmissionError) -> Self {
32        match e {
33            TransmissionError::Cancelled => PipelineError::Cancelled,
34            other => PipelineError::Transmission(other),
35        }
36    }
37}
38
39impl From<FittingError> for PipelineError {
40    fn from(e: FittingError) -> Self {
41        PipelineError::Fitting(e)
42    }
43}