textX will raise an error if a syntax or semantic error is detected during meta-model or model parsing/construction.
For a syntax error
TextXSyntaxError is raised. For a semantic error
TextXSemanticError is raised. Both exceptions inherit from
exceptions are located in
All exceptions have
message attribute with the error message, and
col attributes which represent line and column where the error was found.
You can also raise
TextXSemanticError during semantic checks (e.g. in object
processors. These error classes accepts the message
and location information (
filename) which can be produced from
any textX model object using
from textx import get_location, TextXSemanticError ... def my_processor(entity): ... check something raise TextXSemanticError('Invalid entity', **get_location(entity)) ...
See also textx command/tool for (meta)model checking from command line.