use serde::Serialize; #[derive(Debug, thiserror::Error)] pub enum AppError { #[error("IO error: {0}")] Io(String), #[error("Not found: {0}")] NotFound(String), #[error("Already exists: {0}")] AlreadyExists(String), #[error("No workspace is open")] NoWorkspace, } impl Serialize for AppError { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { serializer.serialize_str(&self.to_string()) } } impl From for AppError { fn from(err: std::io::Error) -> Self { AppError::Io(err.to_string()) } }