rs_opw_kinematics/
parameter_error.rs1use std::io;
4
5#[derive(Debug)]
7pub enum ParameterError {
8 IoError(io::Error),
9 ParseError(String),
10 MissingField(String),
11 WrongAngle(String),
12 InvalidLength { expected: usize, found: usize },
13 XmlProcessingError(String),
14 ParameterPopulationError(String),
15 KinematicsConfigurationError(String),
16}
17
18impl std::fmt::Display for ParameterError {
19 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
20 match *self {
21 ParameterError::IoError(ref err) =>
22 write!(f, "IO Error: {}", err),
23 ParameterError::ParseError(ref msg) =>
24 write!(f, "Parse Error: {}", msg),
25 ParameterError::WrongAngle(ref msg) =>
26 write!(f, "Wrong angle representation: {}", msg),
27 ParameterError::MissingField(ref field) =>
28 write!(f, "Missing Field: {}", field),
29 ParameterError::InvalidLength { expected, found } =>
30 write!(f, "Invalid Length: expected {}, found {}", expected, found),
31 ParameterError::XmlProcessingError(ref err) =>
32 write!(f, "XML Processing Error: {}", err),
33 ParameterError::ParameterPopulationError(ref err) =>
34 write!(f, "Parameter Population Error: {}", err),
35 ParameterError::KinematicsConfigurationError(ref err) =>
36 write!(f, "Kinematics Configuration Error: {}", err),
37 }
38 }
39}
40
41impl From<io::Error> for ParameterError {
42 fn from(err: io::Error) -> Self {
43 ParameterError::IoError(err)
44 }
45}