libpt_log/
error.rs

1//! # Error module for [`pt-log`](crate)
2//!
3//! This module handles errors in logging contexts.
4
5use anyhow;
6use thiserror::Error;
7use tracing::subscriber::SetGlobalDefaultError;
8/// ## Errors for the [Logger](super::Logger)
9#[derive(Error, Debug)]
10pub enum Error {
11    /// Bad IO operation
12    #[error("Bad IO operation")]
13    IO(#[from] std::io::Error),
14    /// Various errors raised when the messenger is used in a wrong way
15    #[error("Bad usage")]
16    Usage(String),
17    /// Could not assign logger as the global default
18    #[error("Could not assign logger as global default")]
19    SetGlobalDefaultFail(#[from] SetGlobalDefaultError),
20    /// any other error type, wrapped in [anyhow::Error]
21    #[error(transparent)]
22    Other(#[from] anyhow::Error),
23}