use thiserror::Error; #[derive(Debug, Error)] pub enum Error { #[error("sqlite: {0}")] Sqlite(#[from] rusqlite::Error), #[error("io: {0}")] Io(#[from] std::io::Error), #[error("invalid unit: {0}")] InvalidUnit(String), #[error("invalid resistance type: {0}")] InvalidResistanceType(String), #[error("invalid effort kind: {0}")] InvalidEffortKind(String), #[error( "effort kind mismatch: exercise is {exercise} but payload is {payload}" )] EffortKindMismatch { exercise: &'static str, payload: &'static str, }, #[error("tag name cannot be empty")] InvalidTagName, #[error("exercise name cannot be empty")] InvalidExerciseName, #[error("not found: {0}")] NotFound(String), #[error("rpe must be 1..=5, got {0}")] InvalidRpe(i32), #[error("reps must be non-negative, got {0}")] InvalidReps(i32), #[error("load must be a finite non-negative number, got {0}")] InvalidLoad(f64), #[error("increment must be a finite non-negative number, got {0}")] InvalidIncrement(f64), #[error("duration must be non-negative seconds, got {0}")] InvalidDuration(i32), #[error("distance must be a finite non-negative number of meters, got {0}")] InvalidDistance(f64), #[error("could not parse {field}: {value:?}")] ParseField { field: &'static str, value: String }, }