Skip to content

exceptions

plantdb.commons.fsdb.exceptions Link

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
95
96
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

Bases: Exception

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

FileNotFoundError Link

FileNotFoundError(fs, f_id)

Bases: Exception

Could not find the file.

Source code in plantdb/commons/fsdb/exceptions.py
88
89
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
81
82
def __init__(self, scan: 'Scan', fs_id: str) -> None:
    super().__init__(f"Fileset id '{fs_id}' already exists in scan '{scan.id}'!")

FilesetNoIDError Link

Bases: Exception

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

FilesetNotFoundError Link

FilesetNotFoundError(scan, fs_id)

Bases: Exception

Could not find the fileset directory.

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

ScanExistsError Link

ScanExistsError(db, scan_id)

Bases: Exception

Could not find the scan directory.

Source code in plantdb/commons/fsdb/exceptions.py
67
68
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
60
61
def __init__(self, db: 'FSDB', scan_id: str) -> None:
    super().__init__(f"Unknown scan id '{scan_id}' in database '{db.path()}'!")