Skip to content

Exceptions ​

NyanSQLite exports these exception classes:

ExceptionWhen it occurs
NyanSQLiteErrorBase class for the library-specific exceptions below
ModelNotRegisteredErrorA model is used before registration
FieldNotFoundErrorA field is absent from the model
QueryValidationErrorA filter or pagination value is invalid
SearchNotEnabledErrorsearch() is called on a model without searchable fields
TableNameCollisionErrorDifferent models map to the same table name
SchemaMismatchErrorAn existing table differs from the model being registered

Invalid model input or update values raise Pydantic's ValidationError. SQLite failures retain APSW or sqlite3 exception types; they are not wrapped in NyanSQLiteError.

python
from pydantic import ValidationError
from nyansqlite import NyanSQLiteError, SchemaMismatchError

try:
    # Register a model or perform an operation.
    ...
except SchemaMismatchError:
    # Explicit schema migration is required.
    ...
except ValidationError:
    # A model value is invalid.
    ...
except NyanSQLiteError:
    # Another library-specific error occurred.
    ...