Skip to content

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.

csharp
public sealed record RescueWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<RescueWidget>

Inheritance

ObjectHex1bWidgetRescueWidget

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).
csharp
public RescueWidget(Hex1bWidget? Child)

Properties

Child

The child widget to render (may throw during any lifecycle phase).

Returns: Hex1bWidget

csharp
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

csharp
public bool ShowDetails { get; init; }

Methods

OnRescue(Action<RescueEventArgs>)

Sets a synchronous handler called when an exception is caught.

Parameters:

Returns: RescueWidget

A new RescueWidget with the handler set.

csharp
public RescueWidget OnRescue(Action<RescueEventArgs> handler)

OnRescue(Func<RescueEventArgs, Task>)

Sets an asynchronous handler called when an exception is caught.

Parameters:

Returns: RescueWidget

A new RescueWidget with the handler set.

csharp
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:

Returns: RescueWidget

A new RescueWidget with the handler set.

csharp
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:

Returns: RescueWidget

A new RescueWidget with the handler set.

csharp
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:

Returns: RescueWidget

A new RescueWidget with the custom fallback.

csharp
public RescueWidget WithFallback(Func<RescueContext, Hex1bWidget> builder)

Released under the MIT License.