weirdnet_code_spaces/
error.rs1#[derive(Debug, thiserror::Error)]
6pub enum SpacesError {
7 #[error("invalid {what}: {msg}")]
9 Invalid { what: &'static str, msg: String },
10 #[error("missing {what}: {hint}")]
12 Missing { what: &'static str, hint: String },
13 #[error("{0}")]
15 Build(String),
16 #[error(transparent)]
17 Io(#[from] std::io::Error),
18}
19
20impl SpacesError {
21 pub fn invalid(what: &'static str, msg: impl Into<String>) -> Self {
22 SpacesError::Invalid { what, msg: msg.into() }
23 }
24 pub fn missing(what: &'static str, hint: impl Into<String>) -> Self {
25 SpacesError::Missing { what, hint: hint.into() }
26 }
27}
28
29pub(crate) type Error = SpacesError;
30pub type Result<T> = std::result::Result<T, SpacesError>;