mirror of https://github.com/zkat/miette.git
feat: add fancy-no-backtrace feature
This commit is contained in:
parent
70e84f9a01
commit
c268c5ca70
|
|
@ -38,7 +38,7 @@ syn = { version = "1.0", features = ["full"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
fancy = [
|
fancy-no-backtrace = [
|
||||||
"owo-colors",
|
"owo-colors",
|
||||||
"atty",
|
"atty",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
|
|
@ -46,6 +46,9 @@ fancy = [
|
||||||
"supports-hyperlinks",
|
"supports-hyperlinks",
|
||||||
"supports-color",
|
"supports-color",
|
||||||
"supports-unicode",
|
"supports-unicode",
|
||||||
|
]
|
||||||
|
fancy = [
|
||||||
|
"fancy-no-backtrace",
|
||||||
"backtrace",
|
"backtrace",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ pub use ReportHandler as EyreContext;
|
||||||
#[allow(unreachable_pub)]
|
#[allow(unreachable_pub)]
|
||||||
pub use WrapErr as Context;
|
pub use WrapErr as Context;
|
||||||
|
|
||||||
#[cfg(not(feature = "fancy"))]
|
#[cfg(not(feature = "fancy-no-backtrace"))]
|
||||||
use crate::DebugReportHandler;
|
use crate::DebugReportHandler;
|
||||||
use crate::Diagnostic;
|
use crate::Diagnostic;
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
use crate::MietteHandler;
|
use crate::MietteHandler;
|
||||||
|
|
||||||
use error::ErrorImpl;
|
use error::ErrorImpl;
|
||||||
|
|
@ -98,9 +98,9 @@ fn capture_handler(error: &(dyn Diagnostic + 'static)) -> Box<dyn ReportHandler>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_default_printer(_err: &(dyn Diagnostic + 'static)) -> Box<dyn ReportHandler + 'static> {
|
fn get_default_printer(_err: &(dyn Diagnostic + 'static)) -> Box<dyn ReportHandler + 'static> {
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
return Box::new(MietteHandler::new());
|
return Box::new(MietteHandler::new());
|
||||||
#[cfg(not(feature = "fancy"))]
|
#[cfg(not(feature = "fancy-no-backtrace"))]
|
||||||
return Box::new(DebugReportHandler::new());
|
return Box::new(DebugReportHandler::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,20 +5,20 @@ Reporters included with `miette`.
|
||||||
#[allow(unreachable_pub)]
|
#[allow(unreachable_pub)]
|
||||||
pub use debug::*;
|
pub use debug::*;
|
||||||
#[allow(unreachable_pub)]
|
#[allow(unreachable_pub)]
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
pub use graphical::*;
|
pub use graphical::*;
|
||||||
#[allow(unreachable_pub)]
|
#[allow(unreachable_pub)]
|
||||||
pub use json::*;
|
pub use json::*;
|
||||||
#[allow(unreachable_pub)]
|
#[allow(unreachable_pub)]
|
||||||
pub use narratable::*;
|
pub use narratable::*;
|
||||||
#[allow(unreachable_pub)]
|
#[allow(unreachable_pub)]
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
pub use theme::*;
|
pub use theme::*;
|
||||||
|
|
||||||
mod debug;
|
mod debug;
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
mod graphical;
|
mod graphical;
|
||||||
mod json;
|
mod json;
|
||||||
mod narratable;
|
mod narratable;
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
mod theme;
|
mod theme;
|
||||||
|
|
|
||||||
|
|
@ -531,7 +531,7 @@ pub use miette_derive::*;
|
||||||
|
|
||||||
pub use error::*;
|
pub use error::*;
|
||||||
pub use eyreish::*;
|
pub use eyreish::*;
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
pub use handler::*;
|
pub use handler::*;
|
||||||
pub use handlers::*;
|
pub use handlers::*;
|
||||||
pub use named_source::*;
|
pub use named_source::*;
|
||||||
|
|
@ -542,7 +542,7 @@ pub use protocol::*;
|
||||||
mod chain;
|
mod chain;
|
||||||
mod error;
|
mod error;
|
||||||
mod eyreish;
|
mod eyreish;
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
mod handler;
|
mod handler;
|
||||||
mod handlers;
|
mod handlers;
|
||||||
mod named_source;
|
mod named_source;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#![cfg(feature = "fancy")]
|
#![cfg(feature = "fancy-no-backtrace")]
|
||||||
|
|
||||||
use miette::{
|
use miette::{
|
||||||
Diagnostic, GraphicalReportHandler, GraphicalTheme, MietteError, NamedSource,
|
Diagnostic, GraphicalReportHandler, GraphicalTheme, MietteError, NamedSource,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#![cfg(feature = "fancy")]
|
#![cfg(feature = "fancy-no-backtrace")]
|
||||||
|
|
||||||
use miette::{Diagnostic, MietteError, NamedSource, NarratableReportHandler, Report, SourceSpan};
|
use miette::{Diagnostic, MietteError, NamedSource, NarratableReportHandler, Report, SourceSpan};
|
||||||
|
|
||||||
|
|
@ -9,8 +9,8 @@ use thiserror::Error;
|
||||||
fn fmt_report(diag: Report) -> String {
|
fn fmt_report(diag: Report) -> String {
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
// Mostly for dev purposes.
|
// Mostly for dev purposes.
|
||||||
if cfg!(feature = "fancy") && std::env::var("STYLE").is_ok() {
|
if cfg!(feature = "fancy-no-backtrace") && std::env::var("STYLE").is_ok() {
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
GraphicalReportHandler::new_themed(GraphicalTheme::unicode())
|
GraphicalReportHandler::new_themed(GraphicalTheme::unicode())
|
||||||
.render_report(&mut out, diag.as_ref())
|
.render_report(&mut out, diag.as_ref())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue