differential_equations/error.rs
1use thiserror::Error;
2
3/// Invalid data supplied while constructing a problem or algorithm.
4///
5/// Construction errors are separate from [`crate::SolveError`] so callers can
6/// distinguish invalid configuration from failures that occur while stepping.
7#[derive(Clone, Copy, Debug, Eq, Error, PartialEq)]
8#[non_exhaustive]
9pub enum ConfigurationError {
10 /// A required state, matrix collection, or coefficient collection is empty.
11 #[error("{context} must be non-empty")]
12 EmptyData {
13 /// The input whose contents were required.
14 context: &'static str,
15 },
16 /// Computing a required dense dimension overflowed `usize`.
17 #[error("{context} dimension overflow")]
18 DimensionOverflow {
19 /// The object whose dimension could not be represented.
20 context: &'static str,
21 },
22 /// Related state or matrix dimensions do not agree.
23 #[error("{context} dimensions do not match")]
24 DimensionMismatch {
25 /// The object with inconsistent dimensions.
26 context: &'static str,
27 },
28 /// Configuration data contains a NaN or infinity.
29 #[error("{context} must contain only finite values")]
30 NonFiniteData {
31 /// The input containing a non-finite value.
32 context: &'static str,
33 },
34 /// A scalar algorithm parameter lies outside its supported domain.
35 #[error("invalid {parameter}: {reason}")]
36 InvalidParameter {
37 /// The parameter name.
38 parameter: &'static str,
39 /// Its required domain or relationship.
40 reason: &'static str,
41 },
42 /// A set of related bounds is non-finite, unordered, or otherwise invalid.
43 #[error("invalid {context}: {reason}")]
44 InvalidBounds {
45 /// The bounded object being configured.
46 context: &'static str,
47 /// The required relationship between its bounds.
48 reason: &'static str,
49 },
50}