| 1 |
use thiserror::Error; |
| 2 |
|
| 3 |
#[derive(Debug, Error)] |
| 4 |
pub enum Error { |
| 5 |
#[error("sqlite: {0}")] |
| 6 |
Sqlite(#[from] rusqlite::Error), |
| 7 |
|
| 8 |
#[error("io: {0}")] |
| 9 |
Io(#[from] std::io::Error), |
| 10 |
|
| 11 |
#[error("invalid unit: {0}")] |
| 12 |
InvalidUnit(String), |
| 13 |
|
| 14 |
#[error("invalid resistance type: {0}")] |
| 15 |
InvalidResistanceType(String), |
| 16 |
|
| 17 |
#[error("invalid effort kind: {0}")] |
| 18 |
InvalidEffortKind(String), |
| 19 |
|
| 20 |
#[error( |
| 21 |
"effort kind mismatch: exercise is {exercise} but payload is {payload}" |
| 22 |
)] |
| 23 |
EffortKindMismatch { |
| 24 |
exercise: &'static str, |
| 25 |
payload: &'static str, |
| 26 |
}, |
| 27 |
|
| 28 |
#[error("tag name cannot be empty")] |
| 29 |
InvalidTagName, |
| 30 |
|
| 31 |
#[error("exercise name cannot be empty")] |
| 32 |
InvalidExerciseName, |
| 33 |
|
| 34 |
#[error("not found: {0}")] |
| 35 |
NotFound(String), |
| 36 |
|
| 37 |
#[error("rpe must be 1..=5, got {0}")] |
| 38 |
InvalidRpe(i32), |
| 39 |
|
| 40 |
#[error("reps must be non-negative, got {0}")] |
| 41 |
InvalidReps(i32), |
| 42 |
|
| 43 |
#[error("load must be a finite non-negative number, got {0}")] |
| 44 |
InvalidLoad(f64), |
| 45 |
|
| 46 |
#[error("increment must be a finite non-negative number, got {0}")] |
| 47 |
InvalidIncrement(f64), |
| 48 |
|
| 49 |
#[error("duration must be non-negative seconds, got {0}")] |
| 50 |
InvalidDuration(i32), |
| 51 |
|
| 52 |
#[error("distance must be a finite non-negative number of meters, got {0}")] |
| 53 |
InvalidDistance(f64), |
| 54 |
|
| 55 |
#[error("could not parse {field}: {value:?}")] |
| 56 |
ParseField { field: &'static str, value: String }, |
| 57 |
} |
| 58 |
|