use std::path::Path;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("no wipe board found in `{0}` or any parent directory; run `wipe init` first")]
NotInitialized(String),
#[error("a wipe board already exists at `{0}`")]
AlreadyInitialized(String),
#[error("ticket `{0}` not found")]
TicketNotFound(String),
#[error("list `{0}` not found")]
ListNotFound(String),
#[error("forum thread `{0}` not found")]
ThreadNotFound(String),
#[error("forum post `{0}` not found")]
PostNotFound(String),
#[error("{0}")]
Message(String),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Json(#[from] serde_json::Error),
}
impl Error {
pub fn msg(m: impl Into<String>) -> Self {
Error::Message(m.into())
}
pub fn not_initialized(p: impl AsRef<Path>) -> Self {
Error::NotInitialized(p.as_ref().display().to_string())
}
}