TomlLoadError
Base classes
| Name |
Children |
Inherits |
Exception builtins Common base class for all non-exit exceptions. |
|
|
⋔ Inheritance diagram
graph TD
1239253289["base.TomlLoadError"]
1615621424["builtins.Exception"]
3224121899["builtins.BaseException"]
2751680898["builtins.object"]
1615621424 --> 1239253289
3224121899 --> 1615621424
2751680898 --> 3224121899
🛈 DocStrings
Bases: Exception
Unified exception for all TOML parsing errors.
Source code in src/anyenv/toml_tools/base.py
| class TomlLoadError(Exception):
"""Unified exception for all TOML parsing errors."""
def __init__(
self,
message: str,
*,
line: int | None = None,
column: int | None = None,
source_path: str | Path | None = None,
source_content: str | None = None,
) -> None:
super().__init__(message)
self.info = ParseErrorInfo(
message=message,
format_name="TOML Parse",
line=line,
column=column,
source_path=source_path,
source_content=source_content,
)
@property
def line(self) -> int | None:
"""Line number where the error occurred."""
return self.info.line
@property
def column(self) -> int | None:
"""Column number where the error occurred."""
return self.info.column
@property
def source_path(self) -> str | Path | None:
"""Path to the source file that caused the error."""
return self.info.source_path
@property
def source_content(self) -> str | None:
"""Source content that caused the error."""
return self.info.source_content
def format(self, context_lines: int = 2, use_color: bool = True) -> str:
"""Format error with source context for display.
Args:
context_lines: Number of lines to show before/after the error line.
use_color: Whether to include ANSI color codes.
"""
return self.info.format(context_lines=context_lines, use_color=use_color)
|
Column number where the error occurred.
Line number where the error occurred.
source_content
property
source_content: str | None
Source content that caused the error.
source_path: str | Path | None
Path to the source file that caused the error.
format(context_lines: int = 2, use_color: bool = True) -> str
Format error with source context for display.
Parameters:
| Name |
Type |
Description |
Default |
context_lines
|
int
|
Number of lines to show before/after the error line.
|
2
|
use_color
|
bool
|
Whether to include ANSI color codes.
|
True
|
Source code in src/anyenv/toml_tools/base.py
| def format(self, context_lines: int = 2, use_color: bool = True) -> str:
"""Format error with source context for display.
Args:
context_lines: Number of lines to show before/after the error line.
use_color: Whether to include ANSI color codes.
"""
return self.info.format(context_lines=context_lines, use_color=use_color)
|
:fa-brands-github: Show source on GitHub