Skip to main content

refprop/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum RefpropError {
5    /// Error returned by a REFPROP routine (ierr > 0).
6    #[error("REFPROP error {code}: {message}")]
7    Refprop { code: i32, message: String },
8
9    /// Warning returned by a REFPROP routine (ierr < 0).
10    /// The result *may* still be usable.
11    #[error("REFPROP warning {code}: {message}")]
12    Warning { code: i32, message: String },
13
14    /// The REFPROP DLL/so could not be loaded.
15    #[error("REFPROP library not found: {0}")]
16    LibraryNotFound(String),
17
18    /// A fluid `.FLD` file was not found in the fluids directory.
19    #[error("Fluid file not found: {0}")]
20    FluidNotFound(String),
21
22    /// Invalid or out-of-range input.
23    #[error("Invalid input: {0}")]
24    InvalidInput(String),
25
26    /// Catch-all for calculation failures.
27    #[error("Calculation failed: {0}")]
28    CalculationFailed(String),
29}
30
31pub type Result<T> = std::result::Result<T, RefpropError>;