A file-based task manager
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 #[allow(dead_code)] 24 #[error("An unexpected error occurred: {0}")] 25 Oops(Box<dyn std::error::Error>), 26} 27 28impl From<Infallible> for Error { 29 fn from(_: Infallible) -> Self { 30 unreachable!(); 31 } 32}