mirror of https://github.com/zkat/miette.git
Formatting
This commit is contained in:
parent
b1f3b3df26
commit
89c9325457
|
|
@ -56,7 +56,7 @@ pub struct MietteHandlerOpts {
|
||||||
pub(crate) footer: Option<String>,
|
pub(crate) footer: Option<String>,
|
||||||
pub(crate) context_lines: Option<usize>,
|
pub(crate) context_lines: Option<usize>,
|
||||||
pub(crate) tab_width: Option<usize>,
|
pub(crate) tab_width: Option<usize>,
|
||||||
pub(crate) with_cause_chain: Option<bool>
|
pub(crate) with_cause_chain: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MietteHandlerOpts {
|
impl MietteHandlerOpts {
|
||||||
|
|
@ -87,7 +87,7 @@ impl MietteHandlerOpts {
|
||||||
self.width = Some(width);
|
self.width = Some(width);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Include the cause chain of the top-level error in the report.
|
/// Include the cause chain of the top-level error in the report.
|
||||||
pub fn with_cause_chain(mut self) -> Self {
|
pub fn with_cause_chain(mut self) -> Self {
|
||||||
self.with_cause_chain = Some(true);
|
self.with_cause_chain = Some(true);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ pub struct GraphicalReportHandler {
|
||||||
pub(crate) footer: Option<String>,
|
pub(crate) footer: Option<String>,
|
||||||
pub(crate) context_lines: usize,
|
pub(crate) context_lines: usize,
|
||||||
pub(crate) tab_width: Option<usize>,
|
pub(crate) tab_width: Option<usize>,
|
||||||
pub(crate) with_cause_chain: bool
|
pub(crate) with_cause_chain: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
|
@ -49,7 +49,7 @@ impl GraphicalReportHandler {
|
||||||
footer: None,
|
footer: None,
|
||||||
context_lines: 1,
|
context_lines: 1,
|
||||||
tab_width: None,
|
tab_width: None,
|
||||||
with_cause_chain: true
|
with_cause_chain: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ impl GraphicalReportHandler {
|
||||||
footer: None,
|
footer: None,
|
||||||
context_lines: 1,
|
context_lines: 1,
|
||||||
tab_width: None,
|
tab_width: None,
|
||||||
with_cause_chain: true
|
with_cause_chain: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,14 +81,16 @@ impl GraphicalReportHandler {
|
||||||
};
|
};
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Include the cause chain of the top-level error in the graphical output, if available.
|
/// Include the cause chain of the top-level error in the graphical output,
|
||||||
|
/// if available.
|
||||||
pub fn with_cause_chain(mut self) -> Self {
|
pub fn with_cause_chain(mut self) -> Self {
|
||||||
self.with_cause_chain = true;
|
self.with_cause_chain = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not include the cause chain of the top-level error in the graphical output.
|
/// Do not include the cause chain of the top-level error in the graphical
|
||||||
|
/// output.
|
||||||
pub fn without_cause_chain(mut self) -> Self {
|
pub fn without_cause_chain(mut self) -> Self {
|
||||||
self.with_cause_chain = false;
|
self.with_cause_chain = false;
|
||||||
self
|
self
|
||||||
|
|
@ -215,9 +217,9 @@ impl GraphicalReportHandler {
|
||||||
writeln!(f, "{}", textwrap::fill(&diagnostic.to_string(), opts))?;
|
writeln!(f, "{}", textwrap::fill(&diagnostic.to_string(), opts))?;
|
||||||
|
|
||||||
if !self.with_cause_chain {
|
if !self.with_cause_chain {
|
||||||
return Ok(())
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(mut cause_iter) = diagnostic
|
if let Some(mut cause_iter) = diagnostic
|
||||||
.diagnostic_source()
|
.diagnostic_source()
|
||||||
.map(DiagnosticChain::from_diagnostic)
|
.map(DiagnosticChain::from_diagnostic)
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,12 @@ impl NarratableReportHandler {
|
||||||
Self {
|
Self {
|
||||||
footer: None,
|
footer: None,
|
||||||
context_lines: 1,
|
context_lines: 1,
|
||||||
with_cause_chain: true
|
with_cause_chain: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Include the cause chain of the top-level error in the report, if available.
|
/// Include the cause chain of the top-level error in the report, if
|
||||||
|
/// available.
|
||||||
pub fn with_cause_chain(mut self) -> Self {
|
pub fn with_cause_chain(mut self) -> Self {
|
||||||
self.with_cause_chain = true;
|
self.with_cause_chain = true;
|
||||||
self
|
self
|
||||||
|
|
|
||||||
17
src/lib.rs
17
src/lib.rs
|
|
@ -582,15 +582,14 @@
|
||||||
//! `miette` was not developed in a void. It owes enormous credit to various
|
//! `miette` was not developed in a void. It owes enormous credit to various
|
||||||
//! other projects and their authors:
|
//! other projects and their authors:
|
||||||
//!
|
//!
|
||||||
//! - [`anyhow`](http://crates.io/crates/anyhow) and
|
//! - [`anyhow`](http://crates.io/crates/anyhow) and [`color-eyre`](https://crates.io/crates/color-eyre):
|
||||||
//! [`color-eyre`](https://crates.io/crates/color-eyre): these two
|
//! these two enormously influential error handling libraries have pushed
|
||||||
//! enormously influential error handling libraries have pushed forward the
|
//! forward the experience of application-level error handling and error
|
||||||
//! experience of application-level error handling and error reporting.
|
//! reporting. `miette`'s `Report` type is an attempt at a very very rough
|
||||||
//! `miette`'s `Report` type is an attempt at a very very rough version of
|
//! version of their `Report` types.
|
||||||
//! their `Report` types.
|
//! - [`thiserror`](https://crates.io/crates/thiserror) for setting the standard
|
||||||
//! - [`thiserror`](https://crates.io/crates/thiserror) for setting the
|
//! for library-level error definitions, and for being the inspiration behind
|
||||||
//! standard for library-level error definitions, and for being the
|
//! `miette`'s derive macro.
|
||||||
//! inspiration behind `miette`'s derive macro.
|
|
||||||
//! - `rustc` and [@estebank](https://github.com/estebank) for their
|
//! - `rustc` and [@estebank](https://github.com/estebank) for their
|
||||||
//! state-of-the-art work in compiler diagnostics.
|
//! state-of-the-art work in compiler diagnostics.
|
||||||
//! - [`ariadne`](https://crates.io/crates/ariadne) for pushing forward how
|
//! - [`ariadne`](https://crates.io/crates/ariadne) for pushing forward how
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue