base_console/
console_init_error.rs1use std::{error::Error, fmt};
5use tracing::subscriber::SetGlobalDefaultError;
6use tracing_subscriber::filter::FromEnvError;
7
8#[derive(Debug)]
10pub enum ConsoleInitError {
11 Filter(FromEnvError),
13 Subscriber(SetGlobalDefaultError),
15}
16
17impl fmt::Display for ConsoleInitError {
18 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
19 match self {
20 Self::Filter(_) => formatter.write_str("could not configure the console filter"),
21 Self::Subscriber(_) => formatter.write_str("could not install the console subscriber"),
22 }
23 }
24}
25
26impl Error for ConsoleInitError {
27 fn source(&self) -> Option<&(dyn Error + 'static)> {
28 Some(match self {
29 Self::Filter(error) => error,
30 Self::Subscriber(error) => error,
31 })
32 }
33}
34
35impl From<FromEnvError> for ConsoleInitError {
36 fn from(error: FromEnvError) -> Self {
37 Self::Filter(error)
38 }
39}
40
41impl From<SetGlobalDefaultError> for ConsoleInitError {
42 fn from(error: SetGlobalDefaultError) -> Self {
43 Self::Subscriber(error)
44 }
45}