Skip to main content

Traceback

Struct Traceback 

Source
pub struct Traceback {
Show 13 fields pub trace: Trace, pub width: Option<usize>, pub extra_lines: usize, pub theme: Option<String>, pub word_wrap: bool, pub show_locals: bool, pub locals_max_length: Option<usize>, pub locals_max_string: Option<usize>, pub locals_hide_dunder: bool, pub locals_hide_sunder: bool, pub indent_guides: bool, pub suppress: Vec<String>, pub max_frames: usize,
}
Expand description

Traceback display configuration and data.

Holds a Trace and configuration options for rendering. Rendering is not yet implemented - this is the struct definition only.

§Example

use rich_rs::traceback::{Frame, Stack, Trace, Traceback};

let frame = Frame::new("main.rs", 10, "main")
    .with_line("    let x = foo();");

let stack = Stack::new("PanicInfo", "called `Result::unwrap()` on an `Err` value")
    .with_frame(frame);

let trace = Trace::new(vec![stack]);

// Using new() with defaults
let tb = Traceback::new(trace.clone());

// Using builder pattern for customization
let tb = Traceback::builder(trace)
    .width(100)
    .show_locals(true)
    .theme("monokai")
    .build();

Fields§

§trace: Trace

The trace data.

§width: Option<usize>

Display width (None = use console width).

§extra_lines: usize

Number of extra context lines around the error line.

§theme: Option<String>

Syntax highlighting theme name.

§word_wrap: bool

Enable word wrapping of long lines.

§show_locals: bool

Show local variables in each frame.

§locals_max_length: Option<usize>

Maximum length for container locals before abbreviating.

§locals_max_string: Option<usize>

Maximum string length for locals before truncating.

§locals_hide_dunder: bool

Hide locals prefixed with double underscore.

§locals_hide_sunder: bool

Hide locals prefixed with single underscore.

§indent_guides: bool

Show indent guides in code.

§suppress: Vec<String>

Modules/paths to suppress from the traceback.

§max_frames: usize

Maximum number of frames to show (0 = unlimited).

Implementations§

Source§

impl Traceback

Source

pub fn new(trace: Trace) -> Self

Create a new traceback with default settings.

§Arguments
  • trace - The trace data to display.
§Example
use rich_rs::traceback::{Stack, Trace, Traceback};

let trace = Trace::new(vec![Stack::new("Error", "message")]);
let tb = Traceback::new(trace);
Source

pub fn builder(trace: Trace) -> TracebackBuilder

Create a builder for configuring a traceback.

§Arguments
  • trace - The trace data to display.
§Example
use rich_rs::traceback::{Stack, Trace, Traceback};

let trace = Trace::new(vec![Stack::new("Error", "message")]);
let tb = Traceback::builder(trace)
    .show_locals(true)
    .max_frames(50)
    .build();
Source

pub fn trace(&self) -> &Trace

Get the trace data.

Source

pub fn should_show_locals(&self) -> bool

Check if local variables should be displayed.

Source

pub fn filter_locals( &self, locals: &BTreeMap<String, String>, ) -> BTreeMap<String, String>

Filter locals based on hide settings.

Returns a new BTreeMap with hidden variables removed.

Source

pub fn is_suppressed(&self, path: &str) -> bool

Check if a path should be suppressed.

Trait Implementations§

Source§

impl Clone for Traceback

Source§

fn clone(&self) -> Traceback

Returns a duplicate of the value. Read more
1.0.0 · 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, console: &Console<Stdout>, options: &ConsoleOptions, ) -> Segments

Render this object to a sequence of segments.
Source§

fn measure( &self, _console: &Console<Stdout>, options: &ConsoleOptions, ) -> Measurement

Measure the minimum and maximum width requirements. Read more

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.