use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum LoadErrorKind {
Invalid,
Code,
UnknownKey,
Unsupported,
InvalidTarget,
MissingImplementation,
InvalidParams,
DuplicateId,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LoadError {
pub kind: LoadErrorKind,
pub path: String,
pub message: String,
}
impl LoadError {
pub(crate) fn new(kind: LoadErrorKind, path: impl Into<String>, message: impl Into<String>) -> Self {
Self { kind, path: path.into(), message: message.into() }
}
}
impl fmt::Display for LoadError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} at {}", self.message, self.path)
}
}
impl std::error::Error for LoadError {}