1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use *;
/// Extracts the panic message from a `catch_unwind` payload.
///
/// `catch_unwind` returns a `Box<dyn Any + Send>`. The boxed type
/// is whatever the panic site threw — most commonly a `String` /
/// `&str`, but Rust also supports throwing `&'static str` from
/// `std::panic!`. This helper tries each, in order, and falls
/// back to `"<unknown panic payload>"` so the boundary always
/// has a useful message to display.
///
/// # Arguments
///
/// - `&Box<dyn Any + Send>` - The boxed payload from
/// [`std::panic::catch_unwind`].
///
/// # Returns
///
/// - `String` - The recovered panic message.
pub
/// Obtains an `ErrorBoundary` registered against the current hook context slot.
///
/// Behaves like `HookContext::use_hook`: the same `ErrorBoundary` is
/// returned on every render at the same hook index, preserving the
/// `Idle` / `Caught(message)` phase across renders.
///
/// Use [`ErrorBoundary::try_with`] to run a closure under the
/// boundary; panics inside the closure are caught and the phase
/// transitions to `Caught`. The parent's render code reads
/// [`ErrorBoundary::phase`] (a `Signal<ErrorBoundaryPhase>`) to decide
/// whether to render the children or a fallback.
///
/// # Returns
///
/// - `ErrorBoundary` - The error boundary handle.
/// Returns the factory result directly when no hook context is
/// active (e.g. when called outside a render cycle).