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}
25
26impl ParamError {
27 pub fn check_trim(value: &str) -> Result<(), Self> {
29 if !(value == "fb" || value == "f" || value == "b") {
30 return Err(ParamError::InvalidTrimParam {
31 value: value.to_string(),
32 location: Location::caller(),
33 }
34 .into());
35 }
36 Ok(())
37 }
38}