RescueWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A widget that catches exceptions and displays a fallback when errors occur. Similar to React's ErrorBoundary pattern.
public sealed record RescueWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<RescueWidget>Inheritance
Object → Hex1bWidget → RescueWidget
Implements
Constructors
RescueWidget(Hex1bWidget?)
A widget that catches exceptions and displays a fallback when errors occur. Similar to React's ErrorBoundary pattern.
Parameters:
Child(Hex1bWidget): The child widget to render (may throw during any lifecycle phase).
public RescueWidget(Hex1bWidget? Child)Properties
Child
The child widget to render (may throw during any lifecycle phase).
Returns: Hex1bWidget
public Hex1bWidget? Child { get; init; }ShowDetails
Whether to show detailed exception information (stack trace, etc.). Defaults to true in DEBUG builds, false in RELEASE builds.
Returns: Boolean
public bool ShowDetails { get; init; }Methods
OnRescue(Action<RescueEventArgs>)
Sets a synchronous handler called when an exception is caught.
Parameters:
handler(Action<RescueEventArgs>): The handler to invoke when an error occurs.
Returns: RescueWidget
A new RescueWidget with the handler set.
public RescueWidget OnRescue(Action<RescueEventArgs> handler)OnRescue(Func<RescueEventArgs, Task>)
Sets an asynchronous handler called when an exception is caught.
Parameters:
handler(Func<RescueEventArgs, Task>): The async handler to invoke when an error occurs.
Returns: RescueWidget
A new RescueWidget with the handler set.
public RescueWidget OnRescue(Func<RescueEventArgs, Task> handler)OnReset(Action<RescueResetEventArgs>)
Sets a synchronous handler called after the rescue state is reset. This is called after internal cleanup when the user triggers a retry.
Parameters:
handler(Action<RescueResetEventArgs>): The handler to invoke after reset.
Returns: RescueWidget
A new RescueWidget with the handler set.
public RescueWidget OnReset(Action<RescueResetEventArgs> handler)OnReset(Func<RescueResetEventArgs, Task>)
Sets an asynchronous handler called after the rescue state is reset. This is called after internal cleanup when the user triggers a retry.
Parameters:
handler(Func<RescueResetEventArgs, Task>): The async handler to invoke after reset.
Returns: RescueWidget
A new RescueWidget with the handler set.
public RescueWidget OnReset(Func<RescueResetEventArgs, Task> handler)WithFallback(Func<RescueContext, Hex1bWidget>)
Sets a custom fallback builder for rendering the error UI. The builder receives a RescueContext with error information and a Reset() method.
Parameters:
builder(Func<RescueContext, Hex1bWidget>): A function that builds the fallback widget.
Returns: RescueWidget
A new RescueWidget with the custom fallback.
public RescueWidget WithFallback(Func<RescueContext, Hex1bWidget> builder)