TrackErr
A Rust error tracking library that captures error propagation with file locations, and optional timestamps, and contextual messages.
Getting Started
Try the runnable example:
Here's a realistic example of using TrackErr to track errors through multiple layers of an application:
use fs;
use Path;
use ;
// Define error types however preferred (using thiserror for convenience)
Example output when an error occurs:
Error: Database error: Configuration error: Failed to read config file: No such file or directory (os error 2)
Full error trace:
Database error: Configuration error: Failed to read config file: No such file or directory (os error 2)
@ src/main.rs:65:10
Initializing application database
Configuration error: Failed to read config file: No such file or directory (os error 2)
@ src/main.rs:50:10
2026-02-07T10:30:45Z
Failed to read config file: No such file or directory (os error 2)
@ src/main.rs:37:43
Reading database config
No such file or directory (os error 2)
@ UNKNOWN:0:0
API Overview
ErrorExt Trait
Add .track() to any error to capture its location:
.map_err // Capture location when error occurs
ResultExt Trait
Methods for Result<T, Error<E>>:
.track()- Propagate error, convert type, and capture location.ts()- Add timestamp to the current frame.msg(message)- Add contextual message to the current frame
some_result
.track // Convert error type and capture location
.ts // Add timestamp
.msg?; // Add message
Display Formats
- Normal:
format!("{}", error)- Shows only the error message - Alternate:
format!("{:#}", error)- Shows full error chain with locations, timestamps, and messages
Error Flow Example
When printed with {:#}, shows the complete call stack with location tracking.