indexbus_platform_config/
errors.rs

1//! Error types and `Result` aliases.
2//!
3//! **Error semantics**
4//! - Errors are intended to be human-readable and suitable for logs/diagnostics.
5//! - Errors are not intended to be exhaustively pattern-matched for control flow.
6
7/// Result type used by this crate.
8pub type Result<T> = core::result::Result<T, Error>;
9use core::fmt;
10
11/// Errors produced by configuration helpers in this crate.
12#[derive(Debug)]
13pub enum Error {
14    /// A simple, human-readable error message.
15    Message(String),
16}
17
18impl Error {
19    /// Construct an [`Error::Message`].
20    pub fn msg(message: impl Into<String>) -> Self {
21        Self::Message(message.into())
22    }
23}
24
25impl fmt::Display for Error {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        match self {
28            Error::Message(message) => write!(f, "{message}"),
29        }
30    }
31}
32
33#[cfg(feature = "std")]
34impl std::error::Error for Error {}