Skip to content

Commit

Permalink
Improve error information
Browse files Browse the repository at this point in the history
  • Loading branch information
hlbarber committed Dec 12, 2021
1 parent 3e676ed commit 46c9550
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ hostname = "0.3"
serde_json = "1"
futures-channel = "0.3"
futures-util = { version = "0.3", features = ["sink"] }
thiserror = "1"
tokio = { version = "1", features = ["io-util", "net", "time"] }
tokio-rustls = { version = "0.23", optional = true }
tokio-util = { version = "0.6", features = ["codec", "net"] }
Expand Down
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,23 @@ impl Logger {
}

/// The error type for [`Logger`](struct.Logger.html) building.
#[derive(Debug)]
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum BuilderError {
/// Could not resolve the hostname.
HostnameResolution(std::io::Error),
#[error("hostname resolution failed: {0}")]
HostnameResolution(#[source] std::io::Error),
/// Could not coerce the OsString into a string.
#[error("hostname could not be parsed as an OsString: {}", .0.to_string_lossy().as_ref())]
OsString(std::ffi::OsString),
/// Global dispatcher failed.
Global(SetGlobalDefaultError),
#[error("global dispatcher failed to initialize")]
Global(#[source] SetGlobalDefaultError),

/// DNS name error.
#[cfg(feature = "rustls-tls")]
Dns(tokio_rustls::rustls::client::InvalidDnsNameError),
#[error("invalid DNS name: {0}")]
Dns(#[source] tokio_rustls::rustls::client::InvalidDnsNameError),
}

/// A builder for [`Logger`](struct.Logger.html).
Expand Down

0 comments on commit 46c9550

Please sign in to comment.