use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
#[error("{kind}")]
pub(crate) struct Error {
#[source]
pub(super) kind: ErrorKind,
}
impl Error {
pub(super) fn semantic(owner: impl Into<Box<str>>, message: impl Into<Box<str>>) -> Self {
Self {
kind: ErrorKind::Semantic {
owner: owner.into(),
message: message.into(),
},
}
}
}
#[derive(Debug, thiserror::Error)]
pub(super) enum ErrorKind {
#[error("required config {} does not exist", path.display())]
Missing { path: PathBuf },
#[error("config {} is not UTF-8 text", path.display())]
NotText { path: PathBuf },
#[error("failed to parse {}: {source}", path.display())]
Parse {
path: PathBuf,
#[source]
source: toml::de::Error,
},
#[error("unsupported config version {0}; expected version 1")]
UnsupportedVersion(u32),
#[error("{owner}: {message}")]
Semantic { owner: Box<str>, message: Box<str> },
#[error("unknown domain {0:?}")]
UnknownDomain(Box<str>),
#[error("domain {0:?} is registered more than once")]
DuplicateDomain(&'static str),
#[error("domain {name:?}: {source}")]
Domain {
name: Box<str>,
#[source]
source: crate::domain::Error,
},
}