Skip to content

Commit

Permalink
error: fix example of using TracedError with error kind pattern (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaahc authored Mar 13, 2020
1 parent 77624f0 commit 3ec041a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tracing-error/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@ struct Erased;
///
/// ```rust,compile_fail
/// #[derive(Debug, thiserror::Error)]
/// enum Kind {
/// // ...
/// }
///
/// #[derive(Debug)]
/// pub struct Error {
/// source: TracedError<Kind>,
/// backtrace: Backtrace,
/// }
///
/// impl std::error::Error for Error {
/// fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
/// self.source.source()
/// }
///
/// fn backtrace(&self) -> Option<&Backtrace> {
/// Some(&self.backtrace)
/// }
/// }
///
/// impl fmt::Display for Error {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt::Display::fmt(&self.source, fmt)
Expand Down

0 comments on commit 3ec041a

Please sign in to comment.