Module

rendering.plugins.directives.errors

Rich error reporting for directive parsing.

Provides detailed, helpful error messages when directives fail to parse.

Classes

DirectiveError
Rich error for directive parsing failures. Provides detailed context including: - Directive type t…
3

Rich error for directive parsing failures.

Provides detailed context including:

  • Directive type that failed
  • File path and line number
  • Content snippet showing the problem
  • Helpful suggestions for fixing
Inherits from Exception

Methods 1

display
Get formatted error message (same as __str__).
0 str
def display(self) -> str

Get formatted error message (same as str).

Returns

str

Internal Methods 2
__init__
Initialize directive error.
6 None
def __init__(self, directive_type: str, error_message: str, file_path: Path | None = None, line_number: int | None = None, content_snippet: str | None = None, suggestion: str | None = None)

Initialize directive error.

Parameters 6
directive_type str

Type of directive that failed (e.g., 'tabs', 'note')

error_message str

Human-readable error description

file_path Path | None

Path to file containing the directive

line_number int | None

Line number where directive starts

content_snippet str | None

Snippet of content showing the problem

suggestion str | None

Helpful suggestion for fixing the issue

_format_error
Format a rich error message for display.
0 str
def _format_error(self) -> str

Format a rich error message for display.

Returns

str

Functions

format_directive_error
Format a directive error message.
7 str
def format_directive_error(directive_type: str, error_message: str, file_path: Path | None = None, line_number: int | None = None, content_lines: list[str] | None = None, error_line_offset: int = 0, suggestion: str | None = None) -> str

Format a directive error message.

Parameters 7

Name Type Default Description
directive_type str

Type of directive

error_message str

Error description

file_path Path | None None

File containing the error

line_number int | None None

Line number of directive

content_lines list[str] | None None

Lines of content around the error

error_line_offset int 0

Which line in content_lines has the error (for highlighting)

suggestion str | None None

Helpful suggestion

Returns

str

Formatted error message

get_suggestion
Get a helpful suggestion for a common error type.
1 str | None
def get_suggestion(error_key: str) -> str | None

Get a helpful suggestion for a common error type.

Parameters 1

Name Type Default Description
error_key str

Returns

str | None