pub struct ErrorBoundary { /* private fields */ }Expand description
Panic-isolating fault boundary protecting callbacks, reactive effects, and render hooks.
Implementations§
Source§impl ErrorBoundary
Fault-isolation execution, recovery, and telemetry methods for ErrorBoundary.
impl ErrorBoundary
Fault-isolation execution, recovery, and telemetry methods for ErrorBoundary.
Sourcepub fn with_limits<NameType>(
name: NameType,
max_consecutive_faults: u32,
history_limit: usize,
) -> Self
pub fn with_limits<NameType>( name: NameType, max_consecutive_faults: u32, history_limit: usize, ) -> Self
Creates a named ErrorBoundary with explicit consecutive-fault trip threshold and history capacity.
§Arguments
NameType- Diagnostic boundary name.u32- Consecutive panic threshold triggeringErrorBoundaryState::Tripped(clamped to>= 1).usize- Maximum number of recentFaultRecorditems kept in memory.
§Returns
Self- Configured healthy error boundary.
Sourcepub fn guard<CallbackFn, ReturnValue>(
&mut self,
origin: FaultOrigin,
scope: &str,
timestamp_ms: u64,
operation: CallbackFn,
) -> Result<ReturnValue, FaultRecord>where
CallbackFn: FnOnce() -> ReturnValue,
pub fn guard<CallbackFn, ReturnValue>(
&mut self,
origin: FaultOrigin,
scope: &str,
timestamp_ms: u64,
operation: CallbackFn,
) -> Result<ReturnValue, FaultRecord>where
CallbackFn: FnOnce() -> ReturnValue,
Executes operation inside catch_unwind, updating fault telemetry and returning a structured FaultRecord on panic.
§Arguments
FaultOrigin- Runtime site category for fault attribution.&str- Component, effect, or task scope label.u64- Monotonic timestamp in milliseconds.CallbackFn- Protected closure to execute.
§Returns
Result<ReturnValue, FaultRecord>- Operation return value or captured fault record.
Sourcepub fn guard_or<CallbackFn, FallbackFn, ReturnValue>(
&mut self,
origin: FaultOrigin,
scope: &str,
timestamp_ms: u64,
operation: CallbackFn,
fallback: FallbackFn,
) -> ReturnValue
pub fn guard_or<CallbackFn, FallbackFn, ReturnValue>( &mut self, origin: FaultOrigin, scope: &str, timestamp_ms: u64, operation: CallbackFn, fallback: FallbackFn, ) -> ReturnValue
Executes operation under panic isolation, invoking fallback with the captured FaultRecord if it panics.
§Arguments
FaultOrigin- Runtime site category for fault attribution.&str- Component, effect, or task scope label.u64- Monotonic timestamp in milliseconds.CallbackFn- Protected primary closure.FallbackFn- Recovery closure invoked with&FaultRecordon panic.
§Returns
ReturnValue- Primary result or fallback recovery result.
Sourcepub fn recover(&mut self) -> bool
pub fn recover(&mut self) -> bool
Resets a Degraded or Tripped boundary back to Healthy, clearing its consecutive fault counter.
§Returns
bool-truewhen the boundary transitioned out of a faulted state.
Sourcepub fn is_tripped(&self) -> bool
pub fn is_tripped(&self) -> bool
Returns true when the boundary has reached its consecutive-fault trip threshold.
§Returns
bool-truewhenstate == ErrorBoundaryState::Tripped.
Sourcepub fn last_fault(&self) -> Option<&FaultRecord>
pub fn last_fault(&self) -> Option<&FaultRecord>
Returns the most recently intercepted fault record, if any.
§Returns
Option<&FaultRecord>- Latest fault record in the history ring.
Sourcepub fn recent_faults(&self) -> Vec<FaultRecord>
pub fn recent_faults(&self) -> Vec<FaultRecord>
Returns an ordered snapshot of all retained recent fault records (oldest first).
§Returns
Vec<FaultRecord>- Retained fault history snapshot.
Sourcepub fn telemetry(&self) -> ErrorBoundaryTelemetry
pub fn telemetry(&self) -> ErrorBoundaryTelemetry
Captures a compact copyable telemetry snapshot of this error boundary.
§Returns
ErrorBoundaryTelemetry- Current health state and fault counters.