Crates.io | debug_error |
lib.rs | debug_error |
version | 0.1.0 |
created_at | 2025-08-29 20:41:32.555942+00 |
updated_at | 2025-08-29 20:41:32.555942+00 |
description | Lightweight error handling library, which automatically captures the location (file and line) |
homepage | |
repository | https://github.com/OHUVERSE/Rust-Debug-Error |
max_upload_size | |
id | 1816861 |
size | 26,137 |
A lightweight error handling library for Rust that automatically captures file and line information, making debugging significantly easier.
?
operatorlog
crate interface[2025-08-28T13:54:40Z ERROR basic_usage] Created error: This is a test error without automatic logging at examples\basic_usage.rs:37:15
[2025-08-28T13:58:16Z ERROR basic_usage] Error: This error is automatically logged at examples\basic_usage.rs:48:5
use debug_error::{DebugError, debug_error, debug_error_with_log};
use log::info;
fn main() -> Result<(), DebugError> {
// Initialize your logger (env_logger, pretty_env_logger, etc.)
env_logger::init();
info!("Starting application");
// This will return an error with location information
let result = might_fail()?;
Ok(())
}
fn might_fail() -> Result<(), DebugError> {
if some_condition() {
// Automatically logs the error and includes location
Err(debug_error_with_log!("Operation failed due to condition"))?
}
Ok(())
}
fn some_condition() -> bool {
true
}
Add to your Cargo.toml
:
[dependencies]
debug_error = "0.1"
log = "0.4" # Required for logging functionality