RescueNode
Namespace: Hex1b.Nodes
Assembly: Hex1b.dll
A node that catches exceptions and displays a fallback when errors occur. Implements ILayoutProvider to ensure child content is clipped to bounds.
public sealed class RescueNode : Hex1bNode, ILayoutProviderInheritance
Object → Hex1bNode → RescueNode
Implements
Properties
Child
The main child node (may throw during lifecycle methods).
Returns: Hex1bNode
public Hex1bNode? Child { get; set; }ClipMode
The clip mode for the rescue node's content. Always clips to ensure fallback content doesn't overflow.
Returns: ClipMode
public ClipMode ClipMode { get; }ClipRect
The clip rectangle for child content (our bounds).
Returns: Rect
public Rect ClipRect { get; }ErrorPhase
The phase in which the error occurred.
Returns: RescueErrorPhase
public RescueErrorPhase ErrorPhase { get; }Exception
The exception that was caught, if any.
Returns: Exception
public Exception? Exception { get; }FallbackBuilder
Optional custom fallback widget builder.
Returns: Func<RescueContext, Hex1bWidget>
public Func<RescueContext, Hex1bWidget>? FallbackBuilder { get; set; }FallbackChild
The fallback child node (shown when an error occurs).
Returns: Hex1bNode
public Hex1bNode? FallbackChild { get; set; }HasError
Whether an error has occurred.
Returns: Boolean
public bool HasError { get; }ParentLayoutProvider
The parent layout provider, if any. Set when this provider becomes the current layout provider and there was already one active. Used to ensure nested clipping works correctly.
Returns: ILayoutProvider
public ILayoutProvider? ParentLayoutProvider { get; set; }RescueHandler
Handler called when an exception is caught.
Returns: Func<RescueEventArgs, Task>
public Func<RescueEventArgs, Task>? RescueHandler { get; set; }ResetHandler
Handler called after the rescue state is reset.
Returns: Func<RescueResetEventArgs, Task>
public Func<RescueResetEventArgs, Task>? ResetHandler { get; set; }ShowDetails
Whether to show detailed exception information.
Returns: Boolean
public bool ShowDetails { get; set; }SourceWidget
The source widget for event args.
Returns: RescueWidget
public RescueWidget? SourceWidget { get; set; }Methods
ArrangeCore(Rect)
Override this method to implement arranging logic for this node. The base implementation saves previous bounds, marks dirty on change, and sets bounds.
Parameters:
bounds(Rect):
protected override void ArrangeCore(Rect bounds)ClipString(int, int, string)
Clips a string that starts at the given position, returning only the visible portion. Implementations should also consult the ParentLayoutProvider if present.
Parameters:
x(Int32): Starting absolute X position.y(Int32): Absolute Y position.text(String): The text to potentially clip.
Returns: ValueTuple<Int32, String>
A tuple containing:
- adjustedX: The X position to start rendering (may be > x if left-clipped)
- clippedText: The portion of text that should be rendered (may be empty)
public (int adjustedX, string clippedText) ClipString(int x, int y, string text)GetChildren()
Gets the direct children of this node for structural tree traversal. Container nodes should override this to return their children.
Returns: IEnumerable<Hex1bNode>
public override IEnumerable<Hex1bNode> GetChildren()GetFocusableNodes()
Gets all focusable nodes in this subtree (including this node if focusable).
Returns: IEnumerable<Hex1bNode>
public override IEnumerable<Hex1bNode> GetFocusableNodes()MeasureCore(Constraints)
Override this method to implement measuring logic for this node.
Parameters:
constraints(Constraints):
Returns: Size
protected override Size MeasureCore(Constraints constraints)Render(Hex1bRenderContext)
Renders the node to the given context.
Parameters:
context(Hex1bRenderContext):
public override void Render(Hex1bRenderContext context)Reset()
Synchronous reset for use in button callbacks.
public void Reset()ResetAsync()
Resets the error state and invokes the reset handler. Called when the user triggers a retry.
Returns: Task
public Task ResetAsync()ShouldRenderAt(int, int)
Determines if a character at the given absolute position should be rendered. Implementations should also check the ParentLayoutProvider if present.
Parameters:
x(Int32): Absolute X position in terminal coordinates.y(Int32): Absolute Y position in terminal coordinates.
Returns: Boolean
True if the character should be rendered, false if it should be clipped.
public bool ShouldRenderAt(int x, int y)