MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / fmt

Method fmt

crates/core/src/error/error.rs:437–468  ·  view source on GitHub ↗
(&self, f: &mut fmt::Formatter<'_>)

Source from the content-addressed store, hash-verified

435
436impl fmt::Debug for Error {
437 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
438 if f.alternate() {
439 return f.debug_struct("Error").field("inner", &self.inner).finish();
440 }
441
442 let inner = &self.inner;
443 inner.display(f)?;
444
445 if let Some(source) = inner.source() {
446 f.write_str("\n\nCaused by:\n")?;
447 let multiple_causes = source.source().is_some();
448 for (i, e) in source.chain().enumerate() {
449 if multiple_causes {
450 write!(f, "{i: >5}: ")?;
451 } else {
452 write!(f, " ")?;
453 }
454 writeln!(f, "{e}")?;
455 }
456 }
457
458 #[cfg(feature = "backtrace")]
459 {
460 let backtrace = inner.backtrace();
461 if let BacktraceStatus::Captured = backtrace.status() {
462 f.write_str("\nStack backtrace:\n")?;
463 fmt::Display::fmt(backtrace, f)?;
464 }
465 }
466
467 Ok(())
468 }
469}
470
471impl fmt::Display for Error {

Callers

nothing calls this directly

Calls 13

fmtFunction · 0.85
OkFunction · 0.85
chainMethod · 0.80
backtraceMethod · 0.80
statusMethod · 0.80
finishMethod · 0.45
fieldMethod · 0.45
displayMethod · 0.45
sourceMethod · 0.45
write_strMethod · 0.45
is_someMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected