flexi_logger_datadog/
error.rs

1//! Errors
2
3use log::error;
4use std::fmt::Debug;
5use std::io;
6use thiserror::Error;
7
8/// Errors
9#[derive(Error, Debug)]
10pub enum Error {
11    /// Error in HTTP communication
12    #[error("Http Error")]
13    HttpError(#[from] reqwest::Error),
14    /// IO Error
15    #[error("IO Error")]
16    IOError(#[from] io::Error),
17    /// Error acquiring internal lock
18    #[error("Lock Error")]
19    LockError(String),
20    /// Adapter has been shutdown and can no longer be operated on
21    #[error("Adapter is shut down")]
22    AdapterShutdownError,
23    /// Internal channel communication error
24    #[error("Channel communication error: `{0}`")]
25    ChannelError(String),
26}
27
28/// Log error to stderr and at error level
29pub fn log_error<E: std::fmt::Display>(e: E) {
30    error!("Unexpected error: {}", e);
31    eprintln!("Unexpected error: {}", e);
32}