MCPcopy Create free account
hub / github.com/NV404/gova / ErrorBoundary

Function ErrorBoundary

errors.go:14–24  ·  view source on GitHub ↗

ErrorBoundary wraps a child view and catches panics during rendering. Accepts either a View, a Viewable, or a *componentNode. Viewable values are wrapped into a component so their Body() call is guarded. The fallback is registered on the component as a side channel; the rendering path consults it o

(child any, fallback func(err error) View)

Source from the content-addressed store, hash-verified

12// component across re-renders only updates the fallback, instead of
13// nesting panic-recovery wrappers around renderFn.
14func ErrorBoundary(child any, fallback func(err error) View) *viewNode {
15 view := asView(child)
16 if view == nil {
17 return &viewNode{kind: viewKindGroup}
18 }
19 if comp, ok := view.(*componentNode); ok {
20 comp.errFallback = fallback
21 return comp.viewNode()
22 }
23 return view.viewNode()
24}
25
26func toError(r any) error {
27 switch v := r.(type) {

Callers 1

TestErrorBoundaryFunction · 0.85

Calls 2

asViewFunction · 0.85
viewNodeMethod · 0.65

Tested by 1

TestErrorBoundaryFunction · 0.68