Skip to main content

ErrorHandler

Trait ErrorHandler 

Source
pub trait ErrorHandler: Send + Sync {
    // Required method
    fn handle(
        &self,
        name: &str,
        error_msg: &str,
        cycle: u64,
        duration_nanos: u64,
        detail: ErrorDetail,
    ) -> ErrorDetail;
}
Expand description

A single error handler in the chain.

Each handler can:

  • Perform side effects (logging, counting, metering)
  • Transform the ErrorDetail (mark as retryable, change result code)
  • Halt execution (by panicking or returning a stop signal)

Handlers are composable: the chain passes ErrorDetail through each handler in sequence.

Required Methods§

Source

fn handle( &self, name: &str, error_msg: &str, cycle: u64, duration_nanos: u64, detail: ErrorDetail, ) -> ErrorDetail

Handle an error, returning a potentially transformed ErrorDetail.

  • name: error classification name (type name or custom)
  • error_msg: the error message
  • cycle: the cycle number that was executing
  • duration_nanos: how long into the operation the error occurred
  • detail: the current ErrorDetail from upstream handlers

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§