use std::{convert::Infallible, string::FromUtf8Error}; use thiserror::Error as ThisError; pub type Result = std::result::Result; #[derive(ThisError, Debug)] pub enum Error { #[error("The workspace is not initialized. Run `tsk init` to initialize it.")] Uninitialized, #[error("The tsk workspace is already initialized. No change.")] AlreadyInitialized, #[error("Unable to read file: {0}")] Io(#[from] std::io::Error), #[error("Unable to acquire locc: {0}")] Lock(nix::errno::Errno), #[error("Unable to parse id: {0}")] ParseId(#[from] std::num::ParseIntError), #[error("General parsing error: {0}")] Parse(String), #[error("Error parsing bytes as utf-8: {0}")] FromUtf8(#[from] FromUtf8Error), #[error("No tasks on stack")] NoTasks, #[error("No task selected.")] NotSelected, #[allow(dead_code)] #[error("An unexpected error occurred: {0}")] Oops(Box), } impl From for Error { fn from(_: Infallible) -> Self { unreachable!(); } }