pub static mut TRACEBACK_ERROR_CALLBACK: Option<TracebackCallbackType>Expand description
§Traceback Error Callback
The TRACEBACK_ERROR_CALLBACK is a mutable static variable that holds an
optional callback function for custom error handling in a Rust program using
the traceback_error crate. This callback is called when a TracebackError
goes out of scope, allowing you to customize how error information is handled
and reported.
§Usage
To use the TRACEBACK_ERROR_CALLBACK, you can set it to your custom traceback
callback function using the set_traceback! macro.
Your custom traceback callback function should take an argument of type
traceback_error::TracebackError. The macro generates a unique struct and
function to wrap your callback and sets it as the traceback callback.
Example of setting a custom traceback callback:
// Define a custom traceback callback function
fn my_traceback_callback(error: traceback_error::TracebackError) {
// Custom error handling logic here
println!("Custom traceback callback called: {:?}", error);
}
// Use the set_traceback macro to set the custom traceback callback
traceback_error::set_traceback!(my_traceback_callback);
// Any TracebackErrors will now be handled by my_traceback_callback when dropped§Asynchronous Callbacks
If your custom traceback callback is asynchronous, you can specify it as such
using the async keyword when calling the set_traceback! macro.
Example of setting an asynchronous custom traceback callback:
// Define an asynchronous custom traceback callback function
async fn my_async_traceback_callback(error: traceback_error::TracebackError) {
// Custom error handling logic here
println!("Async custom traceback callback called: {:?}", error);
}
// Use the set_traceback macro to set the asynchronous custom traceback callback
traceback_error::set_traceback!(async my_async_traceback_callback);