weirdnet_access/error.rs
1/// Errors from policy changes.
2#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
3pub enum Error {
4 /// A name or value is not valid.
5 #[error("invalid {what}: {msg}")]
6 Invalid {
7 /// What.
8 what: &'static str,
9 /// Why.
10 msg: String,
11 },
12 /// The actor may not do this.
13 #[error("not allowed: {0}")]
14 Denied(String),
15}
16
17impl Error {
18 pub(crate) fn invalid(what: &'static str, msg: impl Into<String>) -> Self {
19 Error::Invalid { what, msg: msg.into() }
20 }
21}
22
23/// `Result` with [`Error`].
24pub type Result<T, E = Error> = std::result::Result<T, E>;