Skip to main content

pcb_toolkit/
error.rs

1/// Errors returned by pcb-toolkit calculation functions.
2#[derive(Debug, thiserror::Error)]
3pub enum CalcError {
4    #[error("W/H ratio {ratio:.3} outside valid range [{min}, {max}]")]
5    InvalidRatio {
6        ratio: f64,
7        min: f64,
8        max: f64,
9    },
10
11    #[error("negative dimension: {name} = {value}")]
12    NegativeDimension { name: &'static str, value: f64 },
13
14    #[error("value out of range: {name} = {value} (expected {expected})")]
15    OutOfRange {
16        name: &'static str,
17        value: f64,
18        expected: &'static str,
19    },
20
21    #[error("unknown material: {0}")]
22    UnknownMaterial(String),
23
24    #[error("unknown copper weight: {0}")]
25    UnknownCopperWeight(String),
26
27    #[error("insufficient inputs: {0}")]
28    InsufficientInputs(&'static str),
29}