Skip to main content

Traceback

Struct Traceback 

Source
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

Source

pub fn new(trace: Trace) -> Self

Create a new Traceback from Trace data.

Source

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.

Source

pub fn width(self, width: usize) -> Self

Builder: set the total output width in characters.

Source

pub fn code_width(self, width: usize) -> Self

Builder: set the width reserved for source code (excluding line numbers).

Source

pub fn extra_lines(self, n: usize) -> Self

Builder: set the number of extra source lines shown before and after the error line.

Source

pub fn theme(self, theme: impl Into<String>) -> Self

Builder: set the theme name (e.g. "monokai", "base16-ocean.dark").

Source

pub fn word_wrap(self, wrap: bool) -> Self

Builder: enable or disable word wrapping of long lines.

Source

pub fn show_locals(self, show: bool) -> Self

Builder: show local variables at each frame when set to true.

Source

pub fn indent_guides(self, guides: bool) -> Self

Builder: enable indentation guides in source context.

Source

pub fn locals_max_length(self, n: usize) -> Self

Builder: set the maximum number of local variables to display per frame.

Source

pub fn locals_max_string(self, n: usize) -> Self

Builder: set the maximum length for local variable string values.

Source

pub fn locals_max_depth(self, n: usize) -> Self

Builder: set the maximum depth for nested local variable display.

Source

pub fn locals_hide_dunder(self, hide: bool) -> Self

Builder: hide locals with dunder names (e.g. __name__) when true.

Source

pub fn locals_hide_sunder(self, hide: bool) -> Self

Builder: hide locals with underscore-prefixed names (e.g. _secret) when true.

Source

pub fn suppress(self, suppress: Vec<String>) -> Self

Builder: suppress frames whose filename matches any of the given patterns.

Source

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 Clone for Traceback

Source§

fn clone(&self) -> Traceback

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Traceback

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Renderable for Traceback

Source§

fn render(&self, options: &ConsoleOptions) -> RenderResult

Render this object into a RenderResult using the provided options. Read more
Source§

fn measure(&self, _options: &ConsoleOptions) -> Option<Measurement>

Optional width-measurement hook (equivalent to __rich_measure__). Override to provide min/max width constraints for layout.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.