weirdnet_themes/error.rs
1//! The crate's error type.
2
3#[derive(Debug, thiserror::Error)]
4pub enum ThemeError {
5 /// A theme, name or role that does not check out (`what` names the thing).
6 #[error("invalid {what}: {msg}")]
7 Invalid { what: &'static str, msg: String },
8 #[error(transparent)]
9 Io(#[from] std::io::Error),
10 #[error("toml: {0}")]
11 TomlSer(#[from] toml::ser::Error),
12}
13
14impl ThemeError {
15 pub fn invalid(what: &'static str, msg: impl Into<String>) -> Self {
16 ThemeError::Invalid { what, msg: msg.into() }
17 }
18}
19
20pub type Result<T> = std::result::Result<T, ThemeError>;