A filesystem-based task manager
at master 1.2 kB view raw
1use std::{convert::Infallible, string::FromUtf8Error}; 2 3use thiserror::Error as ThisError; 4 5pub type Result<T> = std::result::Result<T, Error>; 6 7#[derive(ThisError, Debug)] 8pub enum Error { 9 #[error("The workspace is not initialized. Run `tsk init` to initialize it.")] 10 Uninitialized, 11 #[error("The tsk workspace is already initialized. No change.")] 12 AlreadyInitialized, 13 #[error("Unable to read file: {0}")] 14 Io(#[from] std::io::Error), 15 #[error("Unable to acquire locc: {0}")] 16 Lock(nix::errno::Errno), 17 #[error("Unable to parse id: {0}")] 18 ParseId(#[from] std::num::ParseIntError), 19 #[error("General parsing error: {0}")] 20 Parse(String), 21 #[error("Error parsing bytes as utf-8: {0}")] 22 FromUtf8(#[from] FromUtf8Error), 23 #[error("No tasks on stack")] 24 NoTasks, 25 #[error("No task selected.")] 26 NotSelected, 27 #[allow(dead_code)] 28 #[error("An unexpected error occurred: {0}")] 29 Oops(Box<dyn std::error::Error>), 30 #[error("System time/clock error: {0}")] 31 SystemTime(#[from] std::time::SystemTimeError), 32} 33 34impl From<Infallible> for Error { 35 fn from(_: Infallible) -> Self { 36 unreachable!(); 37 } 38}