mirror of https://github.com/zkat/miette.git
Document `#[diagnostic(transparent)]`
This commit is contained in:
parent
c25676cb1f
commit
8f322567b8
14
src/lib.rs
14
src/lib.rs
|
|
@ -186,7 +186,7 @@
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! // lib/error.rs
|
//! // lib/error.rs
|
||||||
//! use miette::Diagnostic;
|
//! use miette::{Diagnostic, SourceSpan};
|
||||||
//! use thiserror::Error;
|
//! use thiserror::Error;
|
||||||
//!
|
//!
|
||||||
//! #[derive(Error, Diagnostic, Debug)]
|
//! #[derive(Error, Diagnostic, Debug)]
|
||||||
|
|
@ -198,6 +198,18 @@
|
||||||
//! #[error("Oops it blew up")]
|
//! #[error("Oops it blew up")]
|
||||||
//! #[diagnostic(code(my_lib::bad_code))]
|
//! #[diagnostic(code(my_lib::bad_code))]
|
||||||
//! BadThingHappened,
|
//! BadThingHappened,
|
||||||
|
//!
|
||||||
|
//! #[error(transparent)]
|
||||||
|
//! // Use `#[diagnostic(transparent)]` to wrap another [`Diagnostic`]. You won't see labels otherwise
|
||||||
|
//! #[diagnostic(transparent)]
|
||||||
|
//! AnotherError(#[from] AnotherError),
|
||||||
|
//! }
|
||||||
|
//!
|
||||||
|
//! #[derive(Error, Diagnostic, Debug)]
|
||||||
|
//! #[error("another error")]
|
||||||
|
//! pub struct AnotherError {
|
||||||
|
//! #[label("here")]
|
||||||
|
//! pub at: SourceSpan
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue