Skip to main content

tiny_tracing/
errors.rs

1use thiserror::Error;
2
3/// Errors that can occur when configuring and initialising the logger.
4#[derive(Error, Debug, PartialEq, Eq)]
5pub enum LoggerError {
6    /// The supplied format string is not a known [`LogFormat`](crate::LogFormat).
7    ///
8    /// Returned by `LogFormat::from_str`, not by `Logger::init` — the builder
9    /// itself is typed, so this cannot occur when values are passed as enums.
10    #[error("Invalid log format: '{0}'. Valid formats are: 'text', 'json'.")]
11    InvalidFormat(String),
12    /// The env filter string could not be parsed by
13    /// [`EnvFilter`](tracing_subscriber::EnvFilter).
14    #[error("Invalid env filter: '{0}'.")]
15    InvalidEnvFilter(String),
16    /// The log file could not be opened for writing.
17    #[error("Could not open log file '{path}': {message}")]
18    OpenLogFile {
19        /// Path that failed to open.
20        path: String,
21        /// Underlying I/O error message.
22        message: String,
23    },
24    /// A global tracing subscriber is already set (double-init).
25    #[error("Failed to initialize subscriber: {0}")]
26    TryInitError(String),
27}