Crates.io | traceback-error |
lib.rs | traceback-error |
version | 0.1.9 |
source | src |
created_at | 2023-09-11 08:17:14.447803 |
updated_at | 2023-09-14 10:03:06.593029 |
description | This crate aims to make error handling and tracing easier. |
homepage | |
repository | https://github.com/Tommy-ASD/traceback-error |
max_upload_size | |
id | 969320 |
size | 50,723 |
traceback-error is a Rust crate for efficient error handling and traceback functionality. It simplifies error tracking, serialization, and handling in your Rust projects, making it easier to manage and diagnose errors.
Efficient Error Handling: traceback-error provides a structured way to handle errors, allowing you to track and manage them effectively.
Traceback Functionality: Easily create error traces that include detailed information about the error, its location, and any relevant context.
Serialization: Serialize errors to JSON for storage or debugging purposes.
Add this crate to your Cargo.toml:
[dependencies]
traceback-error = "0.1.9"
use traceback_error::{serde_json::json, traceback, TracebackError};
fn main() {
// Should an error occur, handle it
if let Err(e) = do_something_that_might_fail() {
// Handle the error here
// You can also log or serialize it
println!("Error: {}", e);
// Or continue tracing
traceback!(err e, "The thing that might fail failed");
}
}
fn do_something_that_might_fail() -> Result<(), TracebackError> {
// Your code here
// Use the traceback! macro to create and handle errors
Err(traceback!("Something went wrong").with_extra_data(json!({
"details": "Additional information about the error"
})))
}
Documentation is available at docs.rs
Contributions are welcome! Feel free to open issues or pull requests on the GitHub repository. This project is still in very early development, and proper contribution guidelines have not yet been established
This crate is dual-licensed under the MIT License and the Apache License, Version 2.0. You may choose either of these licenses when using this crate. See the LICENSE-MIT and LICENSE-APACHE files for the full text of the licenses.