debug_error_with_log

Macro debug_error_with_log 

Source
macro_rules! debug_error_with_log {
    ($($arg:tt)*) => { ... };
}
Expand description

Creates a DebugError and automatically logs it

This macro creates a DebugError and immediately logs it at the error level. It’s perfect for rapid development when you want immediate visibility into errors. During development you don’t need to match on every low-level function. Just use this macro and you get the location immediately, when you are about to finish you can set up all your error handling and replace this macro with the ‘debug_error’ macro to suppress immediate logging.

§When to Use the macro

  • During initial development and prototyping
  • For quick debugging sessions
  • When you want immediate error visibility

§When NOT to Use (and use ‘debug_error’ macro)

  • Production code (too verbose)
  • When you have proper error handling infrastructure set up already

§Examples

use debug_error::{debug_error_with_log, DebugError};

fn connect_to_database() -> Result<(), DebugError> {
    // Simulate a connection failure
    Err(debug_error_with_log!("Database connection timeout after 30s"))
}