wick_logger/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug, Clone)]
4#[non_exhaustive]
5/// The logger's Error enum.
6pub enum LoggerError {
7  /// Invalid string passed as the log style.
8  #[error("Could not parse log style. Log style should be auto | always | never")]
9  StyleParse,
10
11  /// IO Error.
12  #[error("I/O error: {0}")]
13  IOError(String),
14
15  /// Invalid string passed as the log style.
16  #[error("Could not create logfile {0}")]
17  NoLogfile(String),
18
19  /// Error resolving platform-specific configuration.
20  #[error("Error resolving platform-specific configuration: {0}")]
21  Platform(#[from] wick_xdg::Error),
22
23  /// General initialization error.
24  #[error("Could not initialize logger: {0}")]
25  InitFailed(String),
26}
27
28impl From<std::io::Error> for LoggerError {
29  fn from(e: std::io::Error) -> Self {
30    LoggerError::IOError(e.to_string())
31  }
32}
33impl From<tracing::dispatcher::SetGlobalDefaultError> for LoggerError {
34  fn from(e: tracing::dispatcher::SetGlobalDefaultError) -> Self {
35    LoggerError::InitFailed(e.to_string())
36  }
37}