macro_rules! set_traceback {
    ($callback:ident) => { ... };
    (async $callback:ident) => { ... };
}
Expand description

Sets a custom traceback callback for error handling in a Rust program.

This macro allows you to define and set a custom traceback callback function, which will be called when a TracebackError goes out of scope. The traceback callback provides a way to customize how error information is handled and reported.

Usage

To use this macro, provide the name of the callback function you want to use as the custom traceback callback. This function should take an argument of type utils::error_types::TracebackError. The macro generates a unique struct and function to wrap your callback and sets it as the traceback callback using utils::set_traceback_callback.

Example

// Define a custom traceback callback function
fn my_traceback_callback(error: utils::error_types::TracebackError) {
    // Custom error handling logic here
    println!("Custom traceback callback called: {:?}", error);
}

// Use the set_traceback macro to set the custom traceback callback
set_traceback!(my_traceback_callback);

// Any TracebackErrors will now be handled by my_traceback_callback when dropped
// The same is possible with asynchronous functions
async fn my_traceback_callback(error: utils::error_types::TracebackError) {
    // Custom error handling logic here
    println!("Async custom traceback callback called: {:?}", error);
}

// But you have to specify that it is asynchronous
set_traceback!(async my_traceback_callback);

// Any TracebackErrors will now be handled by my_traceback_callback when dropped