Error
relationalai.semantics.frontend.core
Error = include_in_docs(CoreEntities.Type('Error'))A core Concept for emitting errors.
Use Error.new(...) inside Model.define to record an error
when a condition matches. Each call creates an Error entity with a message and any extra keyword
fields you provide, for example type="InvalidValue" which you can later read as Error.type.
If you define multiple errors, select the ones you want by filtering on Error.message and/or your
context fields (for example Error.type == "InvalidValue").
You can inspect errors explicitly by selecting them, and they also surface as warnings when you run queries.
Examples
Section titled “Examples”Define an error with context:
>>> from relationalai.semantics import Error, Integer, Model, String>>> m = Model()>>> Person = m.Concept("Person")>>> Person.name = m.Property(f"{Person} has {String:name}")>>> Person.age = m.Property(f"{Person} has {Integer:age}")>>> m.define(Person.new(name="Alice", age=10))>>> m.where(Person.age < 18).define(... Error.new(message="Person is too young", person=Person, age=Person.age)... )Select only matching errors:
>>> m.where(Error, Error.message == "Person is too young").select(... Error.message, Error.person.name, Error.age... ).to_df()