pub struct Traceback { /* private fields */ }Expand description
Renders a traceback with Rich formatting.
Mimics Python Rich’s rich.traceback.Traceback renderable.
Implementations§
Source§impl Traceback
impl Traceback
Sourcepub fn from_exception(
exc_type: impl Into<String>,
exc_value: impl Into<String>,
frames: Vec<Frame>,
) -> Self
pub fn from_exception( exc_type: impl Into<String>, exc_value: impl Into<String>, frames: Vec<Frame>, ) -> Self
Convenience constructor: build a Traceback from an exception type,
value, and list of frames.
Sourcepub fn code_width(self, width: usize) -> Self
pub fn code_width(self, width: usize) -> Self
Builder: set the width reserved for source code (excluding line numbers).
Sourcepub fn extra_lines(self, n: usize) -> Self
pub fn extra_lines(self, n: usize) -> Self
Builder: set the number of extra source lines shown before and after the error line.
Sourcepub fn theme(self, theme: impl Into<String>) -> Self
pub fn theme(self, theme: impl Into<String>) -> Self
Builder: set the theme name (e.g. "monokai", "base16-ocean.dark").
Sourcepub fn word_wrap(self, wrap: bool) -> Self
pub fn word_wrap(self, wrap: bool) -> Self
Builder: enable or disable word wrapping of long lines.
Sourcepub fn show_locals(self, show: bool) -> Self
pub fn show_locals(self, show: bool) -> Self
Builder: show local variables at each frame when set to true.
Sourcepub fn indent_guides(self, guides: bool) -> Self
pub fn indent_guides(self, guides: bool) -> Self
Builder: enable indentation guides in source context.
Sourcepub fn locals_max_length(self, n: usize) -> Self
pub fn locals_max_length(self, n: usize) -> Self
Builder: set the maximum number of local variables to display per frame.
Sourcepub fn locals_max_string(self, n: usize) -> Self
pub fn locals_max_string(self, n: usize) -> Self
Builder: set the maximum length for local variable string values.
Sourcepub fn locals_max_depth(self, n: usize) -> Self
pub fn locals_max_depth(self, n: usize) -> Self
Builder: set the maximum depth for nested local variable display.
Sourcepub fn locals_hide_dunder(self, hide: bool) -> Self
pub fn locals_hide_dunder(self, hide: bool) -> Self
Builder: hide locals with dunder names (e.g. __name__) when true.
Sourcepub fn locals_hide_sunder(self, hide: bool) -> Self
pub fn locals_hide_sunder(self, hide: bool) -> Self
Builder: hide locals with underscore-prefixed names (e.g. _secret) when true.
Sourcepub fn suppress(self, suppress: Vec<String>) -> Self
pub fn suppress(self, suppress: Vec<String>) -> Self
Builder: suppress frames whose filename matches any of the given patterns.
Sourcepub fn max_frames(self, n: usize) -> Self
pub fn max_frames(self, n: usize) -> Self
Builder: limit the number of frames shown (remaining are collapsed into a single message).
Trait Implementations§
Source§impl Renderable for Traceback
impl Renderable for Traceback
Source§fn render(&self, options: &ConsoleOptions) -> RenderResult
fn render(&self, options: &ConsoleOptions) -> RenderResult
RenderResult using the provided options. Read moreSource§fn measure(&self, _options: &ConsoleOptions) -> Option<Measurement>
fn measure(&self, _options: &ConsoleOptions) -> Option<Measurement>
__rich_measure__).
Override to provide min/max width constraints for layout.