feat: error boundary support in widget3#7468
Conversation
805be0a to
a1cd50a
Compare
c69e4bf to
e5571a1
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds an Error Boundary concept to the Widget3 renderer so that rendering errors can be caught and replaced with fallback output (instead of failing the whole render), and applies it to squad player rendering.
Changes:
- Added
ERROR_BOUNDARYtype and anErrorBoundaryWidget3 component. - Updated
Widget/Renderer.renderto handle error boundary VNodes viaLogic.tryOrElseLogwith optional fallback rendering. - Wrapped
SquadPlayerDisplayrendering in anErrorBoundaryand added new specs for the behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| lua/wikis/commons/Widget/Types.lua | Adds the ERROR_BOUNDARY render type constant. |
| lua/wikis/commons/Widget/Renderer.lua | Implements error-boundary rendering using Logic.tryOrElseLog and ErrorDisplay. |
| lua/wikis/commons/Widget/ErrorBoundary.lua | Introduces the ErrorBoundary component that emits an ERROR_BOUNDARY VNode. |
| lua/wikis/commons/Widget/Component.lua | Adds LLS type aliases for the new ErrorBoundary VNode/component props. |
| lua/wikis/commons/Squad/Controller.lua | Wraps per-player rendering in an error boundary with a table-row fallback. |
| lua/spec/components_spec.lua | Adds specs for ErrorBoundary behavior (currently inconsistent with implementation). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ---@alias ContextDef<T> {defaultValue: T} | ||
| ---@alias ContextParam<T> {def: ContextDef<T>, value: T, children?: Renderable|Renderable[]} | ||
| ---@alias HtmlParam {classes?: string[], css?: table, attributes?: table, children?: Renderable|Renderable[]} | ||
| ---@alias ErrorParam {children?: Renderable|Renderable[], fallback?: fun(error: Error, context: Context?): Renderable} |
There was a problem hiding this comment.
According to the implementation in Renderer, fallback can also be a Renderable, right?
Or was that one of the cases the annotations cannot express (i remember there being some issues around function annotations)?
There was a problem hiding this comment.
| ---@alias ErrorParam {children?: Renderable|Renderable[], fallback?: fun(error: Error, context: Context?): Renderable} | |
| ---@alias ErrorParam {children?: Renderable|Renderable[], fallback?: (fun(error: Error, context: Context?): Renderable) | Renderable} |
mbergen
left a comment
There was a problem hiding this comment.
Besides comment about annotation, very nice feature!
hjpalpha
left a comment
There was a problem hiding this comment.
lgtm modulo open comment
Summary
Creates error boundary support in Widget3
How did you test this change?
attached test cases