Skip to content

[plan] Enhance error reporting with tree structures for nested errors #12626

@github-actions

Description

@github-actions

Objective

Improve visualization of error chains and nested causes by using lipgloss/tree for hierarchical error rendering.

Context

From discussion #12479 - Go Fan review of charmbracelet/lipgloss usage.

The codebase already uses lipgloss/tree for general hierarchies. Applying this to error reporting would provide clearer visualization of error chains, validation errors with nested causes, and complex error contexts.

Approach

  1. Identify error rendering functions that would benefit from tree structure
  2. Create helper function for converting error chains to tree structure
  3. Implement tree-based rendering for validation errors with nested causes
  4. Test with complex error scenarios (multiple nested errors)
  5. Ensure backward compatibility with existing error output

Files to Modify

  • pkg/console/console.go - Add tree-based error rendering functions
  • Possibly pkg/console/errors.go if error-specific file exists
  • Update error formatting functions to use tree structure
  • Add tests for nested error rendering

Example

// Show error chain as a tree
errorTree := tree.Root("ValidationError").
    Child("SchemaError: Invalid field 'name'").
    Child(tree.Root("TypeError").
        Child("Expected: string").
        Child("Received: number"))

fmt.Fprintln(os.Stderr, errorTree.String())

Acceptance Criteria

  • Error chains visualized as tree structures
  • Nested errors clearly show parent-child relationships
  • Tree rendering respects TTY detection (styled vs plain)
  • Works with existing error types and wrapping
  • No breaking changes to existing error output format
  • Tests cover simple and complex error scenarios

AI generated by Plan Command for discussion #12479

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions