Skip to content

Exceptions

bcql_py.exceptions

Custom exceptions and validation issue types for bcql_py.

BCQLSyntaxError

BCQLSyntaxError(
    error_message: str,
    *,
    bcql_query: str = "",
    error_position: int | None = None,
)

Bases: Exception

A syntax error with optional source and position, raised when tokenization or parsing of a BCQL query fails.

Attributes:

Name Type Description
error_message

Human-readable parse or lexing error message.

bcql_query

Original BCQL source query.

error_position

0-based character position in bcql_query.

__str__

__str__() -> str

Return a readable message including a caret position when available.

ValidationIssue dataclass

ValidationIssue(
    kind: IssueKind,
    message: str,
    node_type: str,
    context: dict[str, Any] = dict(),
)

A single semantic validation problem found during validate(). In practice, there may be multiple issues collected in a BCQLValidationError to report them all at once instead of just the first one.

Attributes:

Name Type Description
kind IssueKind

A short machine-readable label identifying the issue category.

message str

Human-readable description of the problem.

node_type str

The node_type discriminator of the offending AST node.

context dict[str, Any]

Extra context (e.g. the offending annotation name, value, or tag).

__str__

__str__() -> str

Return this issue as a compact single-line message.

BCQLValidationError

BCQLValidationError(issues: list[ValidationIssue])

Bases: Exception

Raised when an AST does not satisfy a CorpusSpec.

Collects one or more ValidationIssue instances so that callers can surface every problem at once (when fail_fast=False) or just the first (default).

Attributes:

Name Type Description
issues

List of ValidationIssue entries describing what went wrong.

__str__

__str__() -> str

Return one issue or a multi-line list of all validation issues as a string.