Skip to main content

piquel_log/
error.rs

1use thiserror::Error;
2
3/// Errors returned while constructing backend components.
4#[derive(Debug, Error)]
5pub enum BuildError {
6    /// File output configuration is invalid.
7    #[cfg(feature = "file")]
8    #[error("invalid file configuration: {0}")]
9    InvalidFileConfig(&'static str),
10
11    /// File sink setup failed.
12    #[cfg(feature = "file")]
13    #[error("file sink I/O error: {0}")]
14    Io(#[from] std::io::Error),
15}
16
17/// Errors returned while installing the backend globally.
18#[derive(Debug, Error)]
19pub enum InitError {
20    /// A global tracing subscriber is already installed.
21    #[error("a global tracing subscriber is already installed")]
22    AlreadyInitialized,
23
24    /// The `log` crate already has a global logger installed.
25    #[cfg(feature = "log")]
26    #[cfg_attr(docsrs, doc(cfg(feature = "log")))]
27    #[error("the global log bridge is already installed")]
28    LogBridgeAlreadyInitialized,
29
30    /// Building the backend failed before installation.
31    #[error(transparent)]
32    Build(#[from] BuildError),
33}