mirror of https://github.com/zkat/miette.git
Clarified semantic similarity with anyhow/eyre types/macros.
This commit is contained in:
parent
ccc97310fa
commit
e49794fc01
|
|
@ -53,8 +53,9 @@ and such might not want.
|
||||||
- Unique error codes on every [`Diagnostic`].
|
- Unique error codes on every [`Diagnostic`].
|
||||||
- Custom links to get more details on error codes.
|
- Custom links to get more details on error codes.
|
||||||
- Super handy derive macro for defining diagnostic metadata.
|
- Super handy derive macro for defining diagnostic metadata.
|
||||||
- [`anyhow`](https://docs.rs/anyhow)/[`eyre`](https://docs.rs/eyre) error
|
- Replacements for [`anyhow`](https://docs.rs/anyhow)/[`eyre`](https://docs.rs/eyre)
|
||||||
wrapper type, [`Report`], which can be returned from `main()`.
|
types [`Result`], [`Report`] and the [`miette!`] macro for the `anyhow!`/`eyre!`
|
||||||
|
macros.
|
||||||
- Generic support for arbitrary [`SourceCode`]s for snippet data, with default
|
- Generic support for arbitrary [`SourceCode`]s for snippet data, with default
|
||||||
support for `String`s included.
|
support for `String`s included.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,10 @@ macro_rules! ensure {
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// ## `anyhow`/`eyre` Users
|
||||||
|
///
|
||||||
|
/// You can just replace `use`s of the `anyhow!`/`eyre!` macros with `miette!`.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! miette {
|
macro_rules! miette {
|
||||||
($msg:literal $(,)?) => {
|
($msg:literal $(,)?) => {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,10 @@ mod wrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Core Diagnostic wrapper type.
|
Core Diagnostic wrapper type.
|
||||||
|
|
||||||
|
## `eyre` Users
|
||||||
|
|
||||||
|
You can just replace `use`s of `eyre::Report` with `miette::Report`.
|
||||||
*/
|
*/
|
||||||
pub struct Report {
|
pub struct Report {
|
||||||
inner: ManuallyDrop<Box<ErrorImpl<()>>>,
|
inner: ManuallyDrop<Box<ErrorImpl<()>>>,
|
||||||
|
|
@ -241,6 +245,11 @@ pub trait ReportHandler: core::any::Any + Send + Sync {
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// ## `anyhow`/`eyre` Users
|
||||||
|
///
|
||||||
|
/// You can just replace `use`s of `anyhow::Result`/`eyre::Result` with
|
||||||
|
/// `miette::Result`.
|
||||||
pub type Result<T, E = Report> = core::result::Result<T, E>;
|
pub type Result<T, E = Report> = core::result::Result<T, E>;
|
||||||
|
|
||||||
/// Provides the `wrap_err` method for `Result`.
|
/// Provides the `wrap_err` method for `Result`.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue