tlq_ucum/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, Error)]
6pub enum Error {
7    #[error("UCUM expression must be ASCII")]
8    NonAscii,
9
10    #[error("UCUM expression must not contain whitespace")]
11    ContainsWhitespace,
12
13    #[error("invalid UCUM syntax at byte {pos}: {message}")]
14    Syntax { pos: usize, message: &'static str },
15
16    #[error("unknown unit symbol '{0}'")]
17    UnknownUnit(String),
18
19    #[error("unit '{0}' does not allow metric prefixes")]
20    NotPrefixable(String),
21
22    #[error("non-linear unit '{0}' is not convertible")]
23    NonLinear(String),
24
25    #[error("cannot apply exponent to affine unit '{0}'")]
26    AffineExponent(String),
27
28    #[error("incompatible units: '{from}' vs '{to}'")]
29    Incompatible { from: String, to: String },
30
31    #[error("unit database error: {0}")]
32    Db(String),
33
34    #[error("numeric overflow")]
35    Overflow,
36}
37