Documentation
¶
Overview ¶
Package errorview renders a structured wrapped-error chain as a collapsing tree: per-stream sub-headers, per-fact rows showing message (red), stack frame triple (monospace muted), and CBOR diagnostic of any attached structured data (in a dark canvas Frame). Lifted out of the logviewer detail pane so any consumer of an `eh.MarshalError`-shaped chain — observability dashboards, crash reports, debug overlays — can render it with the same look without re-implementing the per-fact dispatch and wrap discipline.
Usage:
r := errorview.New(ids, "card-err").DefaultOpen(false) r.Render(ctx)
Renderer is a value type; fluent setters return modified copies so a base config is safe to share. All widget IDs are derived from the caller-supplied WidgetIdStack under the per-Renderer idPrefix, so two renderers on the same stack can't collide as long as their prefixes differ.
Wire-shape adapters live with each consumer (e.g. logviewer.toErrorviewContext bridges factsstore.LogErrorContext → errorview.Context); errorview itself stays decoupled from any particular decoder so it composes with other transports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var PackageProps = packageprops.Props{ WASMWASI: packageprops.WASMCompiles, WASMJS: packageprops.WASMCompiles, WASMFreestanding: packageprops.WASMCompiles, }
PackageProps records this package's curated properties (ADR-0080). Seeded by `wasmsurvey props generate`; curate by hand, then `wasmsurvey props verify`.
Functions ¶
func FormatFrame ¶
FormatFrame composes the Fact's frame triple into a "func @ source:line" string. Exported so callers that want to render frames their own way (without going through the Renderer) reuse the same composition rules. eh's CompactStackTrace already trimmed the longest common path prefix on the producer side, so Source paths arrive at a tractable length.
Types ¶
type Context ¶
type Context struct {
Streams []Stream
}
Context is the typed root of an error chain decode. Empty (zero Streams) is a valid no-op input — the Renderer short-circuits instead of producing an "error chain — 0 streams" header.
type Fact ¶
type Fact struct {
Msg string
Source string
Line string
Function string
Data []byte
DataDiag string
Id uint64
ParentId uint64
}
Fact is one node of an error chain. Mirrors the wire shape that boxer's eh.MarshalError emits per fact:
- Msg: the error's .Error() text (omitted on per-frame stub facts that only carry a stack frame).
- Source / Line / Function: the stack frame triple — present for stack-bearing facts, empty for message-only facts.
- Data / DataDiag: structured-data attached via eb.Build — Data is the raw CBOR, DataDiag the cbor.Diagnose output.
- Id / ParentId: linkage forming the error tree; renderers today display facts in chain order (linear) but the fields are preserved for callers that want to walk the tree shape.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is the configured error-chain viewer. Holds a pointer to the caller's WidgetIdStack so widget IDs derive deterministically from the caller's id scope plus the per-Renderer idPrefix — two renderers on the same stack don't collide as long as their prefixes differ.
Renderer is intentionally a value (not a pointer): config changes don't mutate the caller's instance, which makes a "build a base config once, override per-call" pattern safe.
func New ¶
func New(ids *c.WidgetIdStack, idPrefix string) (inst Renderer)
New builds a Renderer with sensible defaults: DefaultOpen on so freshly-rendered chains reveal their facts immediately, Indent 12 px matching the fieldview default. The idPrefix scopes every widget ID this Renderer emits so multiple renderers can share an ids stack without collisions; pass a stable short string ("card-err" / "log-err" / "trace").
func (Renderer) DefaultOpen ¶
DefaultOpen sets the initial collapsed/expanded state of the per-stream CollapsingHeaders. The outer "error chain — N streams" header tracks the same default. Set false for deep chains where the initial summary should be terse.
func (Renderer) ErrorFg ¶
ErrorFg overrides the foreground colour used for fact messages. Default is a soft red (Tailwind red-300) calibrated to read on the standard dark egui theme. Override when adopting a different theme palette.
func (Renderer) Indent ¶
Indent sets the per-fact left padding before frame triples and structured-data blocks, in pixels. Default 12. Zero is allowed for a flat layout.
func (Renderer) MutedFg ¶
MutedFg overrides the foreground colour used for stack-frame triples. Default is Tailwind gray-400.
func (Renderer) Render ¶
Render draws the error chain at the current ui scope. Outer CollapsingHeader titled "error chain — N stream(s)"; per stream a sub-header titled "<name> · M fact(s)"; per fact a message line, an optional indented frame-triple line, and an optional dark-canvas Frame with the CBOR diagnostic of structured data.
No outer wrapper is added beyond the top-level CollapsingHeader; the caller owns whatever surrounding scope (panel, Frame, dialog) frames the viewer.
Empty contexts (no streams or no facts) short-circuit so the UI doesn't grow an "error chain — 0 streams" header.
type Stream ¶
Stream is one bucket of facts grouped by stack identity. Name is "no-stack" (errors without stack info) or "stack-N" (the Nth deduplicated stack trace shared by one or more wrap levels). Facts are in chain order — the outermost wrap message first, then any per-frame stubs interleaved per the producer's materialize pass.