Module

errors.display

Beautiful error display for CLI.

Provides formatted display of BengalError instances with error codes, suggestions, file locations, and documentation links.

Functions:

display_bengal_error: Display a BengalError with beautiful formatting
beautify_common_exception: Convert common exceptions to user-friendly messages

Note:

This module was moved from bengal.cli.helpers.error_display to
bengal.errors.display to fix layer violations (discovery importing from cli).
The old import path still works for backward compatibility.

Example:

>>> from bengal.errors import BengalRenderingError, ErrorCode
>>> from bengal.errors.display import display_bengal_error
>>> from bengal.output import CLIOutput
>>>
>>> error = BengalRenderingError(
...     "Template not found: single.html",
...     code=ErrorCode.R001,
...     file_path=Path("content/post.md"),
...     suggestion="Check templates/ directory",
... )
>>> display_bengal_error(error, CLIOutput())

See Also:

  • bengal/errors/exceptions.py: BengalError exception hierarchy
  • bengal/errors/codes.py: Error code definitions
  • bengal/cli/helpers/error_handling.py: CLI error decorator

Functions

display_bengal_error 2 None
Display a BengalError with beautiful, structured formatting. **Formats the err…
def display_bengal_error(error: BengalError, cli: CLIOutput) -> None

Display a BengalError with beautiful, structured formatting.

Formats the error with:

  • Error code and category header
  • Main error message
  • File location (clickable in most terminals)
  • Related files for debugging
  • Actionable suggestion
  • Documentation link
Parameters
Name Type Description
error BengalError

The BengalError instance to display.

cli CLIOutput

CLI output helper for formatted printing.

beautify_common_exception 1 tuple[str, str | None] |…
Return (message, suggestion) for common exceptions, or None. Handles exception…
def beautify_common_exception(e: Exception) -> tuple[str, str | None] | None

Return (message, suggestion) for common exceptions, or None.

Handles exceptions from yaml, toml, jinja2, and filesystem operations to provide user-friendly error messages.

Parameters
Name Type Description
e Exception

The exception to beautify.

Returns
tuple[str, str | None] | None