1use std::path::Path;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(thiserror::Error, Debug)]
10pub enum Error {
11 #[error("no wipe board found in `{0}` or any parent directory; run `wipe init` first")]
13 NotInitialized(String),
14
15 #[error("a wipe board already exists at `{0}`")]
17 AlreadyInitialized(String),
18
19 #[error("ticket `{0}` not found")]
21 TicketNotFound(String),
22
23 #[error("list `{0}` not found")]
25 ListNotFound(String),
26
27 #[error("{0}")]
29 Message(String),
30
31 #[error(transparent)]
33 Io(#[from] std::io::Error),
34
35 #[error(transparent)]
37 Json(#[from] serde_json::Error),
38}
39
40impl Error {
41 pub fn msg(m: impl Into<String>) -> Self {
43 Error::Message(m.into())
44 }
45
46 pub fn not_initialized(p: impl AsRef<Path>) -> Self {
48 Error::NotInitialized(p.as_ref().display().to_string())
49 }
50}