Classes
DirectiveError
Rich error for directive parsing failures.
Provides detailed context including:
- Directive type t…
DirectiveError
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
ExceptionMethods 1
display
Get formatted error message (same as __str__).
display
def display(self) -> str
Get formatted error message (same as str).
Returns
str
Internal Methods 2
__init__
Initialize directive error.
__init__
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.
_format_error
def _format_error(self) -> str
Format a rich error message for display.
Returns
str
Functions
format_directive_error
Format a directive error message.
format_directive_error
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
Formatted error messagestr
—
get_suggestion
Get a helpful suggestion for a common error type.
get_suggestion
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