Skip to content

exceptions

Custom FSDB ExceptionsLink

A collection of specialized exception classes designed to handle various error scenarios in a file system database (FSDB) implementation. These exceptions provide clear, specific error handling for database operations, scan management, and fileset manipulations.

Key FeaturesLink

  • Database Validation
    • NotAnFSDBError for invalid database instances
  • Scan Management : exceptions for scan-related errors:
    • ScanExistsError for existing scan directories
    • ScanNotFoundError for missing scan directories
  • Fileset Operations: exceptions for fileset-related errors:
    • FilesetExistsError for existing fileset directories
    • FilesetNotFoundError for missing fileset directories
    • FilesetNoIDError for missing fileset identifiers
  • File Handling: exceptions for file-related issues:
    • FileExistsError for existing file
    • FileNotFoundError for missing file
    • FileNoIDError for missing file identifiers
    • FileNoFileNameError for missing file names

Usage ExamplesLink

>>> # Example of handling scan-related errors
>>> try:
>>>     scan = db.get_scan("non_existent_scan")
>>> except ScanNotFoundError as e:
>>>     print(f"Error: {e}")

>>> # Example of handling fileset errors
>>> try:
>>>     fileset = scan.get_fileset("invalid_fileset")
>>> except FilesetNotFoundError as e:
>>>     print(f"Error: {e}")

FileExistsError Link

FileExistsError(fs, f_id)

Bases: Exception

The file already exists.

Source code in plantdb/commons/fsdb/exceptions.py
111
112
def __init__(self, fs: 'Fileset', f_id: str) -> None:
    super().__init__(f"File id '{f_id}' already exists in scan/fileset '{fs.scan.id}/{fs.id}'!")

FileNoFileNameError Link

Bases: Exception

No 'file' entry could be found for this file.

FileNoIDError Link

FileNoIDError(fs)

Bases: Exception

No 'id' entry could be found for this file.

Source code in plantdb/commons/fsdb/exceptions.py
125
126
def __init__(self, fs: 'Fileset') -> None:
    super().__init__(f"Missing the 'id' entry for a 'File' in scan/fileset '{fs.scan.id}/{fs.id}'!.")

FileNotFoundError Link

FileNotFoundError(fs, f_id)

Bases: Exception

Could not find the file.

Source code in plantdb/commons/fsdb/exceptions.py
104
105
def __init__(self, fs: 'Fileset', f_id: str) -> None:
    super().__init__(f"Unknown file id '{f_id}' in scan/fileset '{fs.scan.id}/{fs.id}'!")

FilesetExistsError Link

FilesetExistsError(scan, fs_id)

Bases: Exception

The fileset directory already exists.

Source code in plantdb/commons/fsdb/exceptions.py
97
98
def __init__(self, scan: 'Scan', fs_id: str) -> None:
    super().__init__(f"Fileset id '{fs_id}' already exists in scan '{scan.id}'!")

FilesetNoIDError Link

FilesetNoIDError(scan)

Bases: Exception

No 'id' entry could be found for this fileset.

Source code in plantdb/commons/fsdb/exceptions.py
118
119
def __init__(self, scan: 'Scan') -> None:
    super().__init__(f"Missing the 'id' entry for a 'Fileset' in scan '{scan.id}'!")

FilesetNotFoundError Link

FilesetNotFoundError(scan, fs_id)

Bases: Exception

Could not find the fileset directory.

Source code in plantdb/commons/fsdb/exceptions.py
90
91
def __init__(self, scan: 'Scan', fs_id: str) -> None:
    super().__init__(f"Unknown fileset id '{fs_id}' in scan '{scan.id}'!")

NoAuthUserError Link

NoAuthUserError(message=None)

Bases: Exception

Could not get an authenticated user.

Source code in plantdb/commons/fsdb/exceptions.py
136
137
def __init__(self, message: str = None) -> None:
    super().__init__(message if message else "No authenticated user!")

ScanExistsError Link

ScanExistsError(db, scan_id)

Bases: Exception

Could not find the scan directory.

Source code in plantdb/commons/fsdb/exceptions.py
69
70
def __init__(self, db: 'FSDB', scan_id: str) -> None:
    super().__init__(f"Scan id '{scan_id}' already exists in database '{db.path()}'!")

ScanNotFoundError Link

ScanNotFoundError(db, scan_id)

Bases: Exception

Could not find the scan directory.

Source code in plantdb/commons/fsdb/exceptions.py
62
63
def __init__(self, db: 'FSDB', scan_id: str) -> None:
    super().__init__(f"Unknown scan id '{scan_id}' in database '{db.path()}'!")

TimeLapseExistsError Link

TimeLapseExistsError(db, tl_id)

Bases: Exception

The timelapse directory already exists.

Source code in plantdb/commons/fsdb/exceptions.py
83
84
def __init__(self, db: 'FSDB', tl_id: str) -> None:
    super().__init__(f"Timelapse id '{tl_id}' already exists in database '{db.path()}'!")

TimeLapseNotFoundError Link

TimeLapseNotFoundError(db, tl_id)

Bases: Exception

Could not find the timelapse directory.

Source code in plantdb/commons/fsdb/exceptions.py
76
77
def __init__(self, db: 'FSDB', tl_id: str) -> None:
    super().__init__(f"Unknown timelapse id '{tl_id}' in database '{db.path()}'!")