54 lines
1.4 KiB
Rust
54 lines
1.4 KiB
Rust
use std::result;
|
|
use std::path::PathBuf;
|
|
|
|
use thiserror::Error;
|
|
use chrono::{NaiveDateTime, DateTime, Local};
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum Error {
|
|
#[error("The command '{0}' is not implemented")]
|
|
UnimplementedCommand(String),
|
|
|
|
#[error("Sqlite error: {0}")]
|
|
Sqlite(#[from] rusqlite::Error),
|
|
|
|
#[error("Could not find home directory :(")]
|
|
NoHomeDir,
|
|
|
|
#[error("The file {0} was not found")]
|
|
FileNotFound(PathBuf),
|
|
|
|
#[error("Error reading the file: {0}")]
|
|
CouldntRead(PathBuf),
|
|
|
|
#[error("Couldn't parse toml file at: {path}\nwith error: {error}")]
|
|
TomlError{ path: PathBuf, error: toml::de::Error},
|
|
|
|
#[error("Couldn't parse yaml file at: {path}\nwith error: {error}")]
|
|
YamlError{ path: PathBuf, error: serde_yaml::Error},
|
|
|
|
#[error("Could not understand '{0}' as a date format.")]
|
|
DateTimeParseError(String),
|
|
|
|
#[error("IOError: {0}")]
|
|
IOError(#[from] std::io::Error),
|
|
|
|
#[error("CSV Error: {0}")]
|
|
CSVError(#[from] csv::Error),
|
|
|
|
#[error("Corrupted data found in the database: {0}")]
|
|
CorruptedData(String),
|
|
|
|
#[error("Trying to parse {0} as a time in your timezone led to no results")]
|
|
NoneLocalTime(String),
|
|
|
|
#[error("Trying to parse {orig} as a time in your timezone led to the ambiguous results {t1} and {t2}")]
|
|
AmbiguousLocalTime {
|
|
orig: String,
|
|
t1: DateTime<Local>,
|
|
t2: DateTime<Local>,
|
|
}
|
|
}
|
|
|
|
pub type Result<T> = result::Result<T, Error>;
|