hpt_common/error/
param.rs1use std::panic::Location;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum ParamError {
8 #[error("Invalid trim parameter: must be one of 'fb', 'f', 'b', got {value} at {location}")]
10 InvalidTrimParam {
11 value: String,
13 location: &'static Location<'static>,
15 },
16 #[error("Axis {axis} is duplicated at {location}")]
18 AxisDuplicated {
19 axis: i64,
21 location: &'static Location<'static>,
23 },
24 #[error("Invalid FFT norm parameter: must be one of 'backward', 'forward', 'ortho', got {value} at {location}")]
26 InvalidFFTNormParam {
27 value: String,
29 location: &'static Location<'static>,
31 },
32}
33
34impl ParamError {
35 pub fn check_trim(value: &str) -> Result<(), Self> {
37 if !(value == "fb" || value == "f" || value == "b") {
38 return Err(ParamError::InvalidTrimParam {
39 value: value.to_string(),
40 location: Location::caller(),
41 }
42 .into());
43 }
44 Ok(())
45 }
46}