mirror of https://gitlab.com/famedly/conduit
Compare commits
8 Commits
6155bdd674
...
2993097715
Author | SHA1 | Date |
---|---|---|
Charles Hall | 2993097715 | 2 weeks ago |
Matthias Ahouansou | cd4e4fe7ac | 2 weeks ago |
Matthias Ahouansou | 0a7ac058a0 | 2 weeks ago |
Daniel Lo Nigro | c90e4816b7 | 2 weeks ago |
Matthias Ahouansou | 2b5295aa29 | 2 weeks ago |
Charles Hall | 10e3adc83c | 3 weeks ago |
Charles Hall | 630a53934a | 3 weeks ago |
Charles Hall | 90f9681d90 | 3 weeks ago |
@ -0,0 +1,64 @@
|
||||
//! Error handling facilities
|
||||
|
||||
use std::{fmt, iter};
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
/// Wraps any [`Error`][e] type so that [`Display`][d] includes its [sources][s]
|
||||
///
|
||||
/// [e]: std::error::Error
|
||||
/// [d]: fmt::Display
|
||||
/// [s]: std::error::Error::source
|
||||
pub struct Chain<'a>(pub &'a dyn std::error::Error);
|
||||
|
||||
impl fmt::Display for Chain<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.0)?;
|
||||
|
||||
let mut source = self.0.source();
|
||||
|
||||
source
|
||||
.into_iter()
|
||||
.chain(iter::from_fn(|| {
|
||||
source = source.and_then(std::error::Error::source);
|
||||
source
|
||||
}))
|
||||
.try_for_each(|source| write!(f, ": {source}"))
|
||||
}
|
||||
}
|
||||
|
||||
/// Top-level errors
|
||||
// Missing docs are allowed here since that kind of information should be
|
||||
// encoded in the error messages themselves anyway.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Main {
|
||||
#[error(
|
||||
"the `CONDUIT_CONFIG` environment variable must either be set to a configuration file path \
|
||||
or set to the empty string to force configuration through environment variables"
|
||||
)]
|
||||
ConfigPathUnset,
|
||||
|
||||
#[error("invalid configuration")]
|
||||
ConfigInvalid(#[from] figment::Error),
|
||||
|
||||
// Upstream's documentation on what this error means is very sparse
|
||||
#[error("opentelemetry error")]
|
||||
Otel(#[from] opentelemetry::trace::TraceError),
|
||||
|
||||
#[error("invalid log filter syntax")]
|
||||
EnvFilter(#[from] tracing_subscriber::filter::ParseError),
|
||||
|
||||
#[error("failed to install global default tracing subscriber")]
|
||||
SetSubscriber(#[from] tracing::subscriber::SetGlobalDefaultError),
|
||||
|
||||
// Upstream's documentation on what this error means is very sparse
|
||||
#[error("tracing_flame error")]
|
||||
TracingFlame(#[from] tracing_flame::Error),
|
||||
|
||||
#[error("failed to load or create the database")]
|
||||
DatabaseError(#[source] crate::utils::error::Error),
|
||||
|
||||
#[error("failed to serve requests")]
|
||||
Serve(#[source] std::io::Error),
|
||||
}
|
Loading…
Reference in New Issue