RIKD63GT7RFV3UAV4BYD57GFXKXALWUP6J7AAHB3M6JVAZ3WFTXAC
DI4CW2M46SOKHZXATOP6HRLZB3A33FCWRFDQBIJHJY2BEDB537NQC
E54DU5UDWVAFMQOBDWIAXWUHXMPMZMWJI6RS7BHD74KULPP6AJRQC
NPOFDGQF4CE72IZBT5Y7KPIBHWPPNOEPBYD5RTUHSVUJ2W4XFRVQC
F5MLEQJFOB443KKN22TYYJN2TR52653MD4VXSEYZQBNWWJYES5VQC
LX7EZ6TKJCQI3K7SV56WMTPFY672WN5UOBGXKKXQI7S73GMWNNXAC
CITEDKPB6MKVZUEYEDE5ZKTNVY35HCOAXKDPYG7YLLEOVFNMSRXQC
HHQUHNVMK5HPDJJ53MBD4IE2TDC3BMQOARPHRQAOO43AWG2LNMOAC
GZZOJ7ZUSBPI3HXIV5UCFNMCDAMZPPLISY2UDV73FDN74HZ3AWJAC
W655S25G7CGI4XOZ2PKITKTH26VJ4QMZFRV2RPYNI4KIUJOIGVMAC
BQU6MTEH6QEW5E2HX3F2AAZ54AHIVDVOEE7FTCQTPLO23U5ILFIQC
UM7DFUYLW4HSMBUDZY3R6ZNJRSX2E75C4DYV3MJAU57EUCGE6JLAC
YOIDJVXQ2EKVCLSHGTWH7I3MAWJKPEASTV5JAFZLQNZLI3LVSASQC
2KK7KO4G4CG4CESDJBPFC2HTB4KPKKOBPOBIJCYCR5I2KNRFPQZAC
ZDN7BJ3JA3VL4AYWX3SV24GHP6NCAETJVAKAXKMIZTLHTWLUNMOQC
45AUHCDJX5A54AYFMJRGDHKMBQ3WYBIPAVPDPY7TCLK5WN5TSROQC
BH2E45KHBW7IX5SZ3Q5ARUILUWYVB3VIXS4BHTGS7W3I6DZGQYWQC
T64LKJ2RTUDFYSJQI7KF4WHZYXZHNEGNOS7ZMMCRIQZ4YN5LOOMAC
// NB: this unwrap can only fail if the underlying error's backtrace
// method is nondeterministic, which would only happen in maliciously
// constructed code
self.inner
.backtrace
.as_ref()
.or_else(|| self.inner.error().backtrace())
.expect("backtrace capture failed")
self.inner.backtrace()
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "{}", self.inner.error())?;
let mut chain = self.chain().skip(1).enumerate().peekable();
if let Some((n, error)) = chain.next() {
write!(f, "\nCaused by:\n ")?;
if chain.peek().is_some() {
write!(f, "{}: ", n)?;
}
writeln!(f, "{}", error)?;
for (n, error) in chain {
writeln!(f, " {}: {}", n, error)?;
}
}
#[cfg(backtrace)]
{
use std::backtrace::BacktraceStatus;
let backtrace = self.backtrace();
match backtrace.status() {
BacktraceStatus::Captured => {
writeln!(f, "\n{}", backtrace)?;
}
BacktraceStatus::Disabled => {
writeln!(
f,
"\nBacktrace disabled; run with RUST_LIB_BACKTRACE=1 environment variable to display a backtrace"
)?;
}
_ => {}
}
}
Ok(())
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
self.inner.debug(formatter)
}
#[cfg(backtrace)]
fn backtrace(&self) -> &Backtrace {
// This unwrap can only panic if the underlying error's backtrace method
// is nondeterministic, which would only happen in maliciously
// constructed code.
self.backtrace
.as_ref()
.or_else(|| self.error().backtrace())
.expect("backtrace capture failed")
fn chain(&self) -> Chain {
Chain {
next: Some(self.error()),
}
}
fn debug(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "{}", self.error())?;
let mut chain = self.chain().skip(1).enumerate().peekable();
if let Some((n, error)) = chain.next() {
write!(f, "\nCaused by:\n ")?;
if chain.peek().is_some() {
write!(f, "{}: ", n)?;
}
writeln!(f, "{}", error)?;
for (n, error) in chain {
writeln!(f, " {}: {}", n, error)?;
}
}
#[cfg(backtrace)]
{
use std::backtrace::BacktraceStatus;
let backtrace = self.backtrace();
match backtrace.status() {
BacktraceStatus::Captured => {
writeln!(f, "\n{}", backtrace)?;
}
BacktraceStatus::Disabled => {
writeln!(
f,
"\nBacktrace disabled; run with RUST_LIB_BACKTRACE=1 environment variable to display a backtrace"
)?;
}
_ => {}
}
}
Ok(())
}
}
impl<E> StdError for ErrorImpl<E> where E: StdError {}
impl<E> Debug for ErrorImpl<E>
where
E: Debug,
{
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let erased = unsafe { &*(self as *const ErrorImpl<E> as *const ErrorImpl<()>) };
erased.debug(formatter)
}
}
impl<E> Display for ErrorImpl<E>
where
E: Display,
{
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Display::fmt(&self.error, formatter)
}
}
impl From<Error> for Box<dyn StdError + Send + Sync + 'static> {
fn from(error: Error) -> Self {
let outer = ManuallyDrop::new(error);
unsafe {
let inner = ptr::read(&outer.inner);
let erased = ManuallyDrop::into_inner(inner);
(erased.vtable.object_boxed)(erased)
}
}