Skip to main content

quad_rs/core/
error.rs

1use super::policy::RangeSplitError;
2use crate::storage::SegmentHeapError;
3
4#[derive(thiserror::Error, Debug, PartialEq)]
5/// Error type for integrator
6pub enum IntegratorError<T, E> {
7    #[error("exceeded the maximum number of function evaluations before convergence")]
8    ExceededMaxFunctionEvaluations,
9    #[error("non-finite error estimate")]
10    NonFiniteErrorEstimate,
11    #[error("no segments found")]
12    NoSegments,
13    #[error("empty integration segment")]
14    EmptySegment,
15    #[error("non-finite integrand at {point:?}")]
16    NonFiniteIntegrand { point: T },
17    #[error("possible singularity at {singularity:?}")]
18    PossibleSingularity { singularity: T },
19    #[error("refined contour piece smaller than minimum")]
20    PieceTooSmall,
21    #[error("error in user code")]
22    User(E),
23}
24
25impl<T, E> From<SegmentHeapError> for IntegratorError<T, E> {
26    fn from(value: SegmentHeapError) -> Self {
27        match value {
28            SegmentHeapError::NonFiniteErrorEstimate => Self::NonFiniteErrorEstimate,
29        }
30    }
31}
32
33impl<T: nalgebra::ComplexField, E> From<RangeSplitError<T>> for IntegratorError<T, E> {
34    fn from(value: RangeSplitError<T>) -> Self {
35        match value {
36            RangeSplitError::SegmentTooSmall { center, .. } => Self::PossibleSingularity {
37                singularity: center,
38            },
39        }
40    }
41}