pub struct ErrorBoundary { /* private fields */ }Expand description
A handle that tracks whether a wrapped subtree has thrown.
The boundary’s phase is exposed via phase() as a
Signal<ErrorBoundaryPhase>. The parent component
reads that signal to decide whether to render the
child or a fallback.
try_with(closure) runs the closure and, if it
panics, transitions the boundary to Caught. The
closure’s return value (if it didn’t panic) is
returned to the caller; if it panicked, an Err
is returned containing the panic message.
Implementations§
Source§impl ErrorBoundary
impl ErrorBoundary
Sourcepub fn phase(&self) -> Signal<ErrorBoundaryPhase>
pub fn phase(&self) -> Signal<ErrorBoundaryPhase>
Returns the underlying phase signal.
Sourcepub fn current(&self) -> ErrorBoundaryPhase
pub fn current(&self) -> ErrorBoundaryPhase
Returns a snapshot of the current phase.
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Returns true if no child has thrown yet.
Sourcepub fn try_with<F, R>(&self, closure: F) -> Result<R, String>where
F: FnOnce() -> R + UnwindSafe,
pub fn try_with<F, R>(&self, closure: F) -> Result<R, String>where
F: FnOnce() -> R + UnwindSafe,
Runs a closure and, if it panics, transitions
the boundary to Caught and returns Err.
On success, the closure’s return value is
returned wrapped in Ok. The closure is
wrapped in AssertUnwindSafe so it does not
have to satisfy UnwindSafe.
Trait Implementations§
Source§impl Clone for ErrorBoundary
impl Clone for ErrorBoundary
Source§fn clone(&self) -> ErrorBoundary
fn clone(&self) -> ErrorBoundary
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more