YNTEYSW7NVBWQLJU45XRK7AWQR5NWFOB4UUVVQ62ERZOO2QJJGAAC
MBJSV73XEUIBF7LU6MUYQJQLCRXYY7LXD7KZZFLLOCEDOKU2EAQAC
CZP5PD5NYLDULLW43VOL6V75CH6DDEJO7H6JSGQSIV2WNSQF4A6QC
4WTZK63JTREYXR3EBW6RRP2TDSA6BXA6E6TOBCIHISNVRHQAWAPAC
EB2Z5XFTQX2SVCOSUYN6HZYCTW6PHLAXGIUV3HSHP72RVR3IDSOAC
F5QLL7RNKWB6DNLUZ7VKGTTYDVCH37YGR26SHZBIVAR37JJMQTXQC
UR5XDZ3SS7QXSUFAYQDYUXX4QDROIYVXUH3Z24F6PAWJDNODAZYAC
3LI5FAF5ULXOWBMTG4XCUOMUPVROSFDY6FWGE574OH4JGPMOPNVAC
CITEDKPB6MKVZUEYEDE5ZKTNVY35HCOAXKDPYG7YLLEOVFNMSRXQC
RIKD63GT7RFV3UAV4BYD57GFXKXALWUP6J7AAHB3M6JVAZ3WFTXAC
XA5ZC3I5O3VTK5LP3IYKWMC6C4F5WPLBPMC7N2JUYRMEKGBYONJAC
2XXEY6VSN7333BBH43IBGNF2FLYJ5OIGFWJPPGUMVCLU6IPJPHSAC
UZFAWKZ7DHFYNB3MKHLZXPKWPEPOC5YF4E6SHKEJG25NBW2XXLRQC
fn print_chain(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.error())?;
let mut chain = self.chain().skip(1).enumerate().peekable();
if let Some((n, error)) = chain.next() {
write!(f, "\n\nCaused by:\n ")?;
if chain.peek().is_some() {
write!(f, "{}: ", n)?;
}
write!(f, "{}", error)?;
for (n, error) in chain {
write!(f, "\n {}: {}", n, error)?;
}
}
Ok(())
}
fn display(&self, f: &mut fmt::Formatter) -> fmt::Result {
if f.alternate() {
self.print_chain(f)
} else {
write!(f, "{}", self.error())
}
}
fn debug(&self, f: &mut fmt::Formatter) -> fmt::Result {
if f.alternate() {
return Debug::fmt(self.error(), f);
}
self.print_chain(f)?;
writeln!(f)?;
#[cfg(backtrace)]
{
use std::backtrace::BacktraceStatus;
let backtrace = self.backtrace();
match backtrace.status() {
BacktraceStatus::Captured => {
let mut backtrace = backtrace.to_string();
if backtrace.starts_with("stack backtrace:") {
// Capitalize to match "Caused by:"
backtrace.replace_range(0..1, "S");
}
write!(f, "\n{}", backtrace)?;
}
BacktraceStatus::Disabled => {
writeln!(
f,
"\nStack backtrace:\n Run with RUST_LIB_BACKTRACE=1 env variable to display a backtrace"
)?;
}
_ => {}
}
}
Ok(())
}
use crate::error::ErrorImpl;
use std::fmt::{self, Debug};
impl ErrorImpl<()> {
fn print_chain(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.error())?;
let mut chain = self.chain().skip(1).enumerate().peekable();
if let Some((n, error)) = chain.next() {
write!(f, "\n\nCaused by:\n ")?;
if chain.peek().is_some() {
write!(f, "{}: ", n)?;
}
write!(f, "{}", error)?;
for (n, error) in chain {
write!(f, "\n {}: {}", n, error)?;
}
}
Ok(())
}
pub(crate) fn display(&self, f: &mut fmt::Formatter) -> fmt::Result {
if f.alternate() {
self.print_chain(f)
} else {
write!(f, "{}", self.error())
}
}
pub(crate) fn debug(&self, f: &mut fmt::Formatter) -> fmt::Result {
if f.alternate() {
return Debug::fmt(self.error(), f);
}
self.print_chain(f)?;
writeln!(f)?;
#[cfg(backtrace)]
{
use std::backtrace::BacktraceStatus;
let backtrace = self.backtrace();
match backtrace.status() {
BacktraceStatus::Captured => {
let mut backtrace = backtrace.to_string();
if backtrace.starts_with("stack backtrace:") {
// Capitalize to match "Caused by:"
backtrace.replace_range(0..1, "S");
}
write!(f, "\n{}", backtrace)?;
}
BacktraceStatus::Disabled => {
writeln!(
f,
"\nStack backtrace:\n Run with RUST_LIB_BACKTRACE=1 env variable to display a backtrace"
)?;
}
_ => {}
}
}
Ok(())
}
}