Trasy
Trasy is a Rust library designed to facilitate rich error handling by integrating traced errors with backtraces. It is particularly useful in applications where detailed context and error origin tracing are critical for debugging and error resolution.
Features
- Traced Errors: Integrates with
tracing_error::SpanTraceto capture and display the context of errors. - Backtrace Support: Optionally attaches backtraces to errors to provide a detailed stack trace when an error occurs.
- Macros for Convenience: Includes macros
error!andbail!to simplify error creation and propagation.
Installation
Add Trasy to your Cargo.toml:
[]
= "0.1.0" # Use the latest version
Usage
Basic Usage
To use Trasy, first import it along with its macros:
use ;
Create and propagate errors easily using the error! macro:
Using Backtrace
To attach a backtrace to your error, simply use the error in a context where the backtrace will be captured:
Implementing for Custom Error Types
Trasy can wrap any error type that implements std::fmt::Debug and std::fmt::Display. Here's how you can implement it for a custom error type:
Implementing with thiserror
use Error;
use TrasyError;
use bail;
Contributing
Contributions to Trasy are welcome! Here are some ways you can contribute:
- Reporting bugs
- Suggesting enhancements
- Adding more integrations and features
- Improving documentation
Please feel free to fork the repository and submit pull requests.