Skip to content

Exceptions

The exceptions Chassis raises.

Each message says what was wrong, with the value, and on a line starting help: what to do instead. Each class is also the built-in exception it is a kind of, so except ValueError catches a bad argument and except FileNotFoundError a missing index. code is the C API's error code for the same error.

ChassisError

Bases: Exception

Base class of every Chassis error.

Source code in chassisdb/exceptions.py
11
12
13
14
class ChassisError(Exception):
    """Base class of every Chassis error."""

    code = 12

CorruptIndexError

Bases: ChassisError

The file is damaged.

Source code in chassisdb/exceptions.py
68
69
70
71
class CorruptIndexError(ChassisError):
    """The file is damaged."""

    code = 9

DimensionMismatchError

Bases: ChassisError, ValueError

A vector or query has another number of components than the index's vectors, or the file holds vectors of other dimensions than asked for.

Source code in chassisdb/exceptions.py
24
25
26
27
28
class DimensionMismatchError(ChassisError, ValueError):
    """A vector or query has another number of components than the index's
    vectors, or the file holds vectors of other dimensions than asked for."""

    code = 2

IdInUseError

Bases: ChassisError, ValueError

The id is already in use.

Source code in chassisdb/exceptions.py
50
51
52
53
class IdInUseError(ChassisError, ValueError):
    """The id is already in use."""

    code = 6

IndexFullError

Bases: ChassisError

The index can hold no more.

Source code in chassisdb/exceptions.py
74
75
76
77
class IndexFullError(ChassisError):
    """The index can hold no more."""

    code = 10

IndexLockedError

Bases: ChassisError

Another writer has the index open.

Source code in chassisdb/exceptions.py
56
57
58
59
class IndexLockedError(ChassisError):
    """Another writer has the index open."""

    code = 7

IndexNotFoundError

Bases: ChassisError, FileNotFoundError

There is no index at the path, or its directory doesn't exist.

Source code in chassisdb/exceptions.py
38
39
40
41
class IndexNotFoundError(ChassisError, FileNotFoundError):
    """There is no index at the path, or its directory doesn't exist."""

    code = 4

InvalidArgumentError

Bases: ChassisError, ValueError

An argument is out of range or malformed: dimensions, an option, an id, a vector with a component that isn't a finite number.

Source code in chassisdb/exceptions.py
17
18
19
20
21
class InvalidArgumentError(ChassisError, ValueError):
    """An argument is out of range or malformed: dimensions, an option, an
    id, a vector with a component that isn't a finite number."""

    code = 1

InvalidPathError

Bases: ChassisError, OSError

The operating system refused: permissions, a full disk, a failed read or write.

Source code in chassisdb/exceptions.py
80
81
82
83
84
class InvalidPathError(ChassisError, OSError):
    """The operating system refused: permissions, a full disk, a failed read
    or write."""

    code = 11

NotAnIndexError

Bases: ChassisError, ValueError

The file is not a Chassis index.

Source code in chassisdb/exceptions.py
44
45
46
47
class NotAnIndexError(ChassisError, ValueError):
    """The file is not a Chassis index."""

    code = 5

NullPointerError

Bases: ChassisError

The library failed without saying why.

Source code in chassisdb/exceptions.py
87
88
89
90
class NullPointerError(ChassisError):
    """The library failed without saying why."""

    code = 12

OptionsMismatchError

Bases: ChassisError, ValueError

The file was created with another metric, precision or max_connections than the one asked for.

Source code in chassisdb/exceptions.py
31
32
33
34
35
class OptionsMismatchError(ChassisError, ValueError):
    """The file was created with another metric, precision or
    max_connections than the one asked for."""

    code = 3

ReadOnlyError

Bases: ChassisError

The index was opened with read_only=True, which only searches.

Source code in chassisdb/exceptions.py
62
63
64
65
class ReadOnlyError(ChassisError):
    """The index was opened with ``read_only=True``, which only searches."""

    code = 8

from_code(code, message)

The exception for a C API error code.

Source code in chassisdb/exceptions.py
111
112
113
def from_code(code: int, message: str) -> ChassisError:
    """The exception for a C API error code."""
    return _BY_CODE.get(code, ChassisError)(message)