Skip to content

Redesign exception display with improved formatting and structure - #444

Merged
ocots merged 1 commit into
exception-presentation-reviewfrom
feat/exception-display-redesign
Jun 9, 2026
Merged

Redesign exception display with improved formatting and structure#444
ocots merged 1 commit into
exception-presentation-reviewfrom
feat/exception-display-redesign

Conversation

@ocots

@ocots ocots commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

This PR redesigns the exception display system to provide a cleaner, more structured, and colorblind-friendly output format.

Key Changes

Display Format Redesign

  • Replaced emoji-based layout with pipe-box structure using separators
  • Type name on first line with caller location when available (e.g., PreconditionError → configure! MyModule.jl:42)
  • Aligned labels (Got, Expected, Reason, Hint, Context, etc.) padded to common width
  • Color coding: red for type name, yellow for warnings, green for hints
  • Dynamic Hint generation for ExtensionError based on weakdeps

Code Refactoring

  • Split monolithic _format_user_friendly_error into modular rendering functions:
    • _build_primary_pairs for type-specific field extraction
    • _render_field for consistent field formatting
    • _render_secondary_pairs for optional fields
    • _render_user_location for caller tracking
  • Added ANSI styling primitives: _dim, _bold, _red, _yellow, _green
  • Improved _format_diagnostic for AmbiguousDescription with human-readable expansions

Documentation Updates

  • Updated docs/src/guide/exceptions.md with new display examples
  • Updated docs/src/index.md to use showerror instead of println
  • Removed context field from ParsingError documentation (was already removed from type)

Test Updates

  • Updated all display tests to match new format (e.g., "Suggestion:" → "Hint ")
  • Tests verify pipe-box structure, aligned labels, and color coding
  • Coverage maintained for all exception types

Benefits

  • Better visual hierarchy with consistent spacing and alignment
  • Colorblind-friendly (no reliance on emoji colors)
  • More scannable with clear section separation
  • Easier to maintain with modular rendering functions
  • Consistent across all exception types

Testing

All tests in test/suite/exceptions/test_exception_display.jl and test/suite/exceptions/test_exceptions.jl pass.

- Refactored display.jl to use modular rendering functions
- Added structured exception context display with sections
- Improved error message formatting with clear hierarchy
- Updated tests to cover new display behavior
- Updated documentation in exceptions.md and index.md
@ocots
ocots merged commit d29535a into exception-presentation-review Jun 9, 2026
6 checks passed
@ocots
ocots deleted the feat/exception-display-redesign branch June 9, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant