Error Classes

This implementation provides individual error classes for all errors defined by the Erbsland Configuration Language. They all share a common base class Error, which allows a convenient “catch-all” error handling while parsing and evaluating the configuration.

The ConfValueNotFound error also subclasses KeyError, to make value lookup match the usual Python conventions.

Interface

class ErrorCategory(*values)

The error category is used to classify errors that occur during parsing or evaluation.

IO = ('IO', 1)

A problem occurred while reading data from an I/O stream.

ENCODING = ('Encoding', 2)

The document contains a problem with UTF-8 encoding.

UNEXPECTED_END = ('UnexpectedEnd', 3)

The document ended unexpectedly.

CHARACTER = ('Character', 4)

The document contains a control character that is not allowed.

SYNTAX = ('Syntax', 5)

The document has a syntax error.

LIMIT_EXCEEDED = ('LimitExceeded', 6)

The size of a name, text, or buffer exceeds the permitted limit.

NAME_CONFLICT = ('NameConflict', 7)

The same name has already been defined earlier in the document.

INDENTATION = ('Indentation', 8)

The indentation of a continued line does not match the previous line.

UNSUPPORTED = ('Unsupported', 9)

The requested feature/version is not supported by this parser.

SIGNATURE = ('Signature', 10)

The document’s signature was rejected.

ACCESS = ('Access', 11)

The document was rejected due to an access check.

VALIDATION = ('Validation', 12)

The document did not meet one of the validation rules.

INTERNAL = ('Internal', 99)

The parser encountered an unexpected internal error.

VALUE_NOT_FOUND = ('ValueNotFound', 101)

A value does not exist.

TYPE_MISMATCH = ('TypeMismatch', 102)

A value exists but has the wrong type for a conversion.

code() int

Return the numeric code of the error category.

class ErrorOutput(*values)

Flags to control the output of errors.

FILENAME_ONLY = 1

Only display the filename, not the full path.

USE_LINES = 2

Break the error message into multiple lines.

DEFAULT = 0

Default format.

exception Error(category: ErrorCategory, message: str, *, source: Source | SourceIdentifier | Location | None = None, position: Position | None = None, path: Path | None = None, system_message: str | None = None, name_path: 'NamePath' | None = None, offset: int | None = None)

Represents a problem encountered while parsing a document or accessing a value.

property category: ErrorCategory

Category of the error.

property code: int

Numeric code of the error category.

property message: str

Human-readable error message.

property location: Location | None

Location where the error occurred, if available.

property path: Path | None

Path associated with the error, if any.

property system_message: str | None

System-specific message describing the error, if any.

property name_path: 'NamePath' | None

Name path of the value that caused the error, if available.

property offset: int | None

Offset of the error from the start of the given source location, if available.

to_text(output: ~erbsland.conf.error.ErrorOutput = <ErrorOutput.DEFAULT: 0>) str

Return a readable string representation of the error.

with_source(source: Source | SourceIdentifier | Location) Error

Return a copy of the error with source replaced.

with_name_path(name_path: NamePath) Error

Return a copy of the error with name_path replaced.

exception ConfIoError(message: str, **kwargs)

Error raised when an I/O operation fails.

exception ConfEncodingError(message: str, **kwargs)

Error raised when UTF-8 encoding is invalid.

exception ConfUnexpectedEnd(message: str, **kwargs)

Error raised when a document ends unexpectedly.

exception ConfCharacterError(message: str, **kwargs)

Error raised for invalid control characters.

exception ConfSyntaxError(message: str, **kwargs)

Error raised for syntax errors in the document.

exception ConfLimitExceeded(message: str, **kwargs)

Error raised when a size limit is exceeded.

exception ConfNameConflict(message: str, **kwargs)

Error raised on name conflicts.

exception ConfIndentationError(message: str, **kwargs)

Error raised for inconsistent indentation in continued lines.

exception ConfUnsupportedError(message: str, **kwargs)

Error raised for features not supported by the parser.

exception ConfSignatureError(message: str, **kwargs)

Error raised when a document’s signature is rejected.

exception ConfAccessError(message: str, **kwargs)

Error raised when a document fails an access check.

exception ConfValidationError(message: str, **kwargs)

Error raised when the document violates validation rules.

exception ConfInternalError(message: str, **kwargs)

Error raised when the parser encounters an unexpected internal issue.

exception ConfValueNotFound(message: str, **kwargs)

Error raised when a requested value is missing.

exception ConfTypeMismatch(message: str, **kwargs)

Error raised when a value has the wrong type for conversion.