Skip to main content

Module stacktrace

Module stacktrace 

Source
Expand description

Stack traces from Rust, Python, Java and JavaScript, in one shape.

parse recognises a trace’s language and normalises it into a StackTrace: the error kind and message, its Frames ordered with the most recent call last (Python’s order), and any chained cause. Each language is a TraceParser; Parsers holds the built-in four and takes more, so other formats plug in without changing this module.

A StackTrace renders with frame locations linked through a Hyperlinker, library frames dimmed and runs of them collapsed, and each cause after the trace it caused. capture and panic_hook build one for the current thread from std::backtrace.

Structs§

Frame
One stack frame.
JavaParser
Parses JVM stack traces with Caused by: chains.
JavaScriptParser
Parses V8 (node, Chrome) stack traces.
Parsers
An ordered set of parsers; the first that detects a trace parses it.
PythonParser
Parses CPython tracebacks, including chained exceptions.
RustParser
Parses std::backtrace output and panic messages.
StackTrace
A normalised stack trace.
StackTraceView
Rendering options for a StackTrace.

Enums§

CauseKind
How a trace relates to its StackTrace::cause.
Language
The language a trace came from.

Constants§

MAX_CAUSES
The most causes the built-in parsers keep, and a view renders, below the outermost error. Traces are untrusted input; a longer chain keeps the causes nearest the error and records how many were left out.

Traits§

TraceParser
Recognises and parses one trace format.

Functions§

capture
The current thread’s backtrace as a Rust StackTrace with message. Frames come from std::backtrace::Backtrace::force_capture, so they need debug info to carry file locations.
panic_hook
A panic hook printing the panic as a StackTrace to console. Install it with std::panic::set_hook(Box::new(panic_hook(console))); this module never installs anything itself.
parse
Parse text with the built-in parsers.