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<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { serializer.serialize_str(&self.to_string()) }} impl From<std::io::Error> for AppError { fn from(err: std::io::Error) -> Self { AppError::Io(err.to_string()) }}
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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(&self.to_string())
}
}
impl From<std::io::Error> for AppError {
fn from(err: std::io::Error) -> Self {
AppError::Io(err.to_string())
}
}