use std::io; use std::fmt; #[derive(Debug)] pub enum Error { Io(io::Error), Serialization(String), NotFound(String), InvalidData(String), WorkspaceNotFound(String), ListNotFound(String), TaskNotFound(String), WebDav(String), Sync(String), Credential(String), } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Error::Io(e) => write!(f, "IO error: {}", e), Error::Serialization(msg) => write!(f, "Serialization error: {}", msg), Error::NotFound(msg) => write!(f, "Not found: {}", msg), Error::InvalidData(msg) => write!(f, "Invalid data: {}", msg), Error::WorkspaceNotFound(name) => write!(f, "Workspace not found: {}", name), Error::ListNotFound(id) => write!(f, "List not found: {}", id), Error::TaskNotFound(id) => write!(f, "Task not found: {}", id), Error::WebDav(msg) => write!(f, "WebDAV error: {}", msg), Error::Sync(msg) => write!(f, "Sync error: {}", msg), Error::Credential(msg) => write!(f, "Credential error: {}", msg), } } } impl std::error::Error for Error {} impl From for Error { fn from(err: io::Error) -> Self { Error::Io(err) } } impl From for Error { fn from(err: serde_json::Error) -> Self { Error::Serialization(err.to_string()) } } impl From for Error { fn from(err: serde_yaml::Error) -> Self { Error::Serialization(err.to_string()) } } impl From for Error { fn from(err: reqwest::Error) -> Self { Error::WebDav(err.to_string()) } } pub type Result = std::result::Result;