Skip to content

Commit

Permalink
Expose the Error type to allow users to set custom error handlers (#…
Browse files Browse the repository at this point in the history
…551)

Expose the `Error` type in the `global` module to allow users to define their own error handlers. This is currently impossible because `Error` is private and therefore users cannot provide a function that satisfies the constraints of `set_error_handler`.
  • Loading branch information
Luca Palmieri committed May 13, 2021
1 parent 133ab27 commit 88e779d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions opentelemetry/src/global/error_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ pub enum Error {
#[cfg(feature = "trace")]
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
#[error(transparent)]
/// Failed to export traces.
Trace(#[from] TraceError),
#[cfg(feature = "metrics")]
#[cfg_attr(docsrs, doc(cfg(feature = "metrics")))]
#[error(transparent)]
/// An issue raised by the metrics module.
Metric(#[from] MetricsError),
#[error("{0}")]
/// Other types of failures not covered by the variants above.
Other(String),
}

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/global/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ mod propagation;
#[cfg(feature = "trace")]
mod trace;

pub use error_handler::{handle_error, set_error_handler};
pub use error_handler::{handle_error, set_error_handler, Error};
#[cfg(feature = "metrics")]
#[cfg_attr(docsrs, doc(cfg(feature = "metrics")))]
pub use metrics::{
Expand Down

0 comments on commit 88e779d

Please sign in to comment.