Error handling
Every exception TileORM raises deliberately is a subclass of TileOrmException. Catch TileOrmException to handle any of them in one place.
from tileorm import TileOrmException
try: truck = await Truck.get(id=1, group="fleet1")except TileOrmException as exc: print(exc)Model definition errors
Section titled “Model definition errors”TileORM checks a model’s fields when you first instantiate it, not when you declare the class.
NoIdentifier— the model has noIdentifier()field.MultipleIdentifiers— the model has more than oneIdentifier()field.NoLocation— the model has no location field (PointField(),BoundsField(), orGeoHashField()).MultipleLocations— the model has more than one location field.
Fix these by changing the model definition. They signal a bug in the model, not bad input data.
Query errors
Section titled “Query errors”NotFoundError—Model.get()orModel.get_by_key()found no object with the given identifier and key.
from tileorm import NotFoundError
try: truck = await Truck.get(id=999, group="fleet1")except NotFoundError: truck = Nonefind() and nearby() do not raise NotFoundError. A search with no matches yields an empty result instead.