use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum TrajectoryError {
#[error("io error on '{path}': {source}")]
Io {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("{path}: row {line} has {got} fields, expected {expected}")]
MissingColumns {
path: PathBuf,
line: usize,
expected: usize,
got: usize,
},
#[error("{path}: row {line} has {got} fields, which is neither {a} nor {b}")]
UnexpectedColumnCount {
path: PathBuf,
line: usize,
got: usize,
a: usize,
b: usize,
},
#[error("{path}: row {line}, field '{field}': '{value}' is not a number")]
InvalidNumber {
path: PathBuf,
line: usize,
field: String,
value: String,
},
#[error("{path}: row {line}: quaternion norm {norm} is not 1")]
InvalidQuaternion {
path: PathBuf,
line: usize,
norm: f64,
},
#[error("{path}: row {line}: timestamp {value} is negative or not finite")]
NegativeTimestamp {
path: PathBuf,
line: usize,
value: f64,
},
#[error("{what}: {got} supplied, {expected} required")]
LengthMismatch {
what: &'static str,
got: usize,
expected: usize,
},
#[error("cannot write EuRoC 17-column layout: this trajectory has no inertial columns")]
MissingInertialColumns,
#[error("unsupported trajectory format: '{0}'")]
UnsupportedFormat(String),
}
pub type Result<T> = std::result::Result<T, TrajectoryError>;