Databases
sql.model.errors
import sql.model.errors
Zuri
sqllifts part of this module out to its own top level; each name below is shown with the path that reaches it. Anything still spelledsql.model.errors.*needsimport sql.model.errors.
The errors that the model layer raises, and the list of errors that a model's own checks add to.
A mistake in how a model is declared, and a record that can't be found,
are database errors, so ModelError and RecordNotFound are subclasses
of sql.SqlError, like everything else that sql raises. A record that
fails validation is different. It's the same kind of failure as an
invalid form, so RecordInvalid is a validate.ValidationError, and
the code that responds to an invalid form with a 422 can respond to an
invalid record in the same way.
Classes
ModelError
class sql.model.ModelError < SqlError
ZuriA model the layer cannot use as it is declared, or a call that asks a model for something it does not have: an association that was never declared, a field that is not a column, an attribute that may not be filled.
- printable — has a
@to_string(), soechoandprint()show something useful
RecordNotFound
class sql.model.RecordNotFound < SqlError
ZuriNo row matched what a record was looked up by.
- printable — has a
@to_string(), soechoandprint()show something useful
Fields
| Field | Type | Description |
|---|---|---|
model |
string |
The name of the model's class. |
key |
any |
What was looked up: the key, or the conditions. |
Constructor
sql.model.RecordNotFound(model, key)
ZuriParameters
model(string)key(any)
RecordInvalid
class sql.model.RecordInvalid < ValidationError
ZuriA record failed its validation, and was not saved.
errors is the list validate reports, one { field, message } per
failure, so validate.Schema.group_errors() and the rest read it as
they read a form's.
catch {
post.save(db)
} as error {
if instance_of(error, RecordInvalid) {
return response.json({ errors: error.errors }, 422)
}
raise error
}
Zuri- printable — has a
@to_string(), soechoandprint()show something useful
Fields
| Field | Type | Description |
|---|---|---|
record |
Model |
The record that failed. |
Constructor
sql.model.RecordInvalid(record, errors)
ZuriParameters
record(Model)errors(list[dict])
RecordInvalid.to_string()
sql.model.RecordInvalid.to_string()
ZuriErrors
class sql.model.Errors
ZuriThe failures a record's validation found, which a model's own
validate() adds to.
validate(errors) {
if self.ends_at != nil and self.ends_at < self.starts_at {
errors.add('ends_at', 'The end has to come after the start.')
}
}
Zuri- printable — has a
@to_string(), soechoandprint()show something useful
Errors.add()
sql.model.Errors.add(field: string, message: string) -> Errors
ZuriRecords a failure.
Parameters
field(string) — The field it concerns.message(string) — What is wrong, as a person should read it.
Returns Errors — This list, for chaining.
Errors.is_empty()
sql.model.Errors.is_empty() -> bool
ZuriWhether nothing has failed.
Returns bool
Errors.length()
sql.model.Errors.length() -> number
ZuriHow many failures there are.
Returns number
Errors.on()
sql.model.Errors.on(field: string) -> list[string]
ZuriThe messages about field.
Parameters
field(string)
Returns list[string]
Errors.list()
sql.model.Errors.list() -> list[dict]
ZuriEvery failure, as { field, message }, in the order they were found.
Returns list[dict]
Errors.to_string()
sql.model.Errors.to_string()
Zuri2026, Richard Ore and Zuri contributors