1use num_dual::linalg::LinAlgError;
2use std::io;
3use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum FeosError {
8 #[error("{0}")]
10 Error(String),
11
12 #[error("`{0}` did not converge within the maximum number of iterations.")]
14 NotConverged(String),
15 #[error("`{0}` encountered illegal values during the iteration.")]
16 IterationFailed(String),
17 #[error("Iteration resulted in trivial solution.")]
18 TrivialSolution,
19 #[error(
20 "Equation of state is initialized for {0} components while the input specifies {1} components."
21 )]
22 IncompatibleComponents(usize, usize),
23 #[error("Invalid state in {0}: {1} = {2}.")]
24 InvalidState(String, String, f64),
25 #[error("Undetermined state: {0}")]
26 UndeterminedState(String),
27 #[error(
28 "Extensive properties can only be evaluated for states that are initialized with extensive properties."
29 )]
30 IntensiveState,
31 #[error("System is supercritical.")]
32 SuperCritical,
33 #[error("No phase split according to stability analysis.")]
34 NoPhaseSplit,
35 #[error("Wrong input units. Expected {0}, got {1}")]
36 WrongUnits(String, String),
37
38 #[error(transparent)]
40 FileIO(#[from] io::Error),
41
42 #[error(transparent)]
44 Serde(#[from] serde_json::Error),
45
46 #[error("The following component(s) were not found: {0}")]
48 ComponentsNotFound(String),
49 #[error(
50 "The identifier '{0}' is not known. ['cas', 'name', 'iupacname', 'smiles', inchi', 'formula']"
51 )]
52 IdentifierNotFound(String),
53 #[error("Information missing.")]
54 InsufficientInformation,
55 #[error("Incompatible parameters: {0}")]
56 IncompatibleParameters(String),
57 #[error("Missing parameters: {0}")]
58 MissingParameters(String),
59
60 #[error(transparent)]
62 LinAlgError(#[from] LinAlgError),
63 #[cfg(feature = "rayon")]
64 #[error(transparent)]
65 RayonError(#[from] rayon::ThreadPoolBuildError),
66 #[cfg(feature = "ndarray")]
67 #[error(transparent)]
68 ShapeError(#[from] ndarray::ShapeError),
69 #[cfg(feature = "rusqlite")]
70 #[error(transparent)]
71 RusqLiteError(#[from] rusqlite::Error),
72}
73
74pub type FeosResult<T> = Result<T, FeosError>;