Struct color_eyre::section::IndentedSection [−][src]
An indented section with a header for an error report
Details
This helper provides two functions to help with constructing nicely formatted error reports. First, it handles indentation of every line of the body for you, and makes sure it is consistent with the rest of color-eyre’s output. Second, it omits outputting the header if the body itself is empty, preventing unnecessary pollution of the report for sections with dynamic content.
Examples
use color_eyre::{eyre::eyre, SectionExt, Help, eyre::Report}; use std::process::Command; use tracing::instrument; trait Output { fn output2(&mut self) -> Result<String, Report>; } impl Output for Command { #[instrument] fn output2(&mut self) -> Result<String, Report> { let output = self.output()?; let stdout = String::from_utf8_lossy(&output.stdout); if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); Err(eyre!("cmd exited with non-zero status code")) .with_section(move || stdout.trim().to_string().header("Stdout:")) .with_section(move || stderr.trim().to_string().header("Stderr:")) } else { Ok(stdout.into()) } } }
Trait Implementations
impl<H, B> Display for IndentedSection<H, B> where
H: Display + Send + Sync + 'static,
B: Display + Send + Sync + 'static,
[src]
H: Display + Send + Sync + 'static,
B: Display + Send + Sync + 'static,
Auto Trait Implementations
impl<H, B> RefUnwindSafe for IndentedSection<H, B> where
B: RefUnwindSafe,
H: RefUnwindSafe,
B: RefUnwindSafe,
H: RefUnwindSafe,
impl<H, B> Send for IndentedSection<H, B> where
B: Send,
H: Send,
B: Send,
H: Send,
impl<H, B> Sync for IndentedSection<H, B> where
B: Sync,
H: Sync,
B: Sync,
H: Sync,
impl<H, B> Unpin for IndentedSection<H, B> where
B: Unpin,
H: Unpin,
B: Unpin,
H: Unpin,
impl<H, B> UnwindSafe for IndentedSection<H, B> where
B: UnwindSafe,
H: UnwindSafe,
B: UnwindSafe,
H: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<D> OwoColorize for D
[src]
pub fn fg<C>(&'a self) -> FgColorDisplay<'a, C, Self> where
C: Color,
[src]
C: Color,
pub fn bg<C>(&'a self) -> BgColorDisplay<'a, C, Self> where
C: Color,
[src]
C: Color,
pub fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
[src]
pub fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
[src]
pub fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
[src]
pub fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
[src]
pub fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
[src]
pub fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
[src]
pub fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
[src]
pub fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
[src]
pub fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
[src]
pub fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
[src]
pub fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
[src]
pub fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
[src]
pub fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
[src]
pub fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
[src]
pub fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
[src]
pub fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
[src]
pub fn white(&'a self) -> FgColorDisplay<'a, White, Self>
[src]
pub fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
[src]
pub fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
[src]
pub fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
[src]
pub fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
[src]
pub fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
[src]
pub fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
[src]
pub fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
[src]
pub fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
[src]
pub fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
[src]
pub fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
[src]
pub fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
[src]
pub fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
[src]
pub fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
[src]
pub fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
[src]
pub fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
[src]
pub fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
[src]
pub fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
[src]
pub fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
[src]
pub fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
[src]
pub fn bold(&'a self) -> BoldDisplay<'a, Self>
[src]
pub fn dimmed(&'a self) -> DimDisplay<'a, Self>
[src]
pub fn italic(&'a self) -> ItalicDisplay<'a, Self>
[src]
pub fn underline(&'a self) -> UnderlineDisplay<'a, Self>
[src]
pub fn blink(&'a self) -> BlinkDisplay<'a, Self>
[src]
pub fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
[src]
pub fn reversed(&'a self) -> ReversedDisplay<'a, Self>
[src]
pub fn hidden(&'a self) -> HiddenDisplay<'a, Self>
[src]
pub fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
[src]
pub fn color<Color>(
&'a self,
color: Color
) -> FgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
[src]
&'a self,
color: Color
) -> FgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
pub fn on_color<Color>(
&'a self,
color: Color
) -> BgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
[src]
&'a self,
color: Color
) -> BgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
pub fn truecolor(
&'a self,
r: u8,
g: u8,
b: u8
) -> FgDynColorDisplay<'a, Rgb, Self>
[src]
&'a self,
r: u8,
g: u8,
b: u8
) -> FgDynColorDisplay<'a, Rgb, Self>
pub fn on_truecolor(
&'a self,
r: u8,
g: u8,
b: u8
) -> BgDynColorDisplay<'a, Rgb, Self>
[src]
&'a self,
r: u8,
g: u8,
b: u8
) -> BgDynColorDisplay<'a, Rgb, Self>
pub fn style(&self, style: Style) -> Styled<&Self>
[src]
impl<T> SectionExt for T where
T: Display + Send + Sync + 'static,
[src]
T: Display + Send + Sync + 'static,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,