Derived units now use a DLUnit class similar to a DLPak to be easily stored and loaded, the public API has been updated to either take a DLUnit object or a Path where it reads the DLUnit from a *.dlunit file The .dlunit file is a ZIP compressed archive containing two files, a manifest.json which stores the units uuid, its input signals and its output signal, and unit.py which is the python code for the unit, the same rules apply (one python function with a specifically structured signature) as when a string was passed in the old API Errors have been added to have a DLUnitError similar to the DLPakError as the DLUnit class is heavily inspired from the DLPak architecutre Logging may still be primitive, this will be covered in the next AI logging sweep to homogenize and clean up the logging aspect of things
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
# Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev>
|
|
# Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
"""Public exceptions raised by DynaLab Core.
|
|
|
|
Catch a subsystem exception when recovery depends on where an operation failed,
|
|
or catch :class:`DynaLabError` to handle every expected library error. The
|
|
``code`` attribute is stable and intended for programmatic decisions; the
|
|
exception message is written for people.
|
|
"""
|
|
|
|
|
|
class DynaLabError(Exception):
|
|
"""Base class for expected errors raised by DynaLab Core."""
|
|
|
|
def __init__(self, message: str, *, code: str) -> None:
|
|
self.code = code
|
|
super().__init__(message)
|
|
|
|
|
|
class CoreError(DynaLabError):
|
|
"""The core cannot perform the requested lifecycle or mode operation."""
|
|
|
|
|
|
class DLPakError(DynaLabError):
|
|
"""A DLPak archive cannot be prepared, read, or written."""
|
|
|
|
|
|
class DLUnitError(DynaLabError):
|
|
"""A DLPak archive cannot be prepared, read, or written."""
|
|
|
|
|
|
class DeriveError(DynaLabError):
|
|
"""A derive unit cannot be created or used as requested."""
|
|
|
|
|
|
class PlaybackError(DynaLabError):
|
|
"""The playback engine cannot perform the requested operation."""
|
|
|
|
|
|
class ConnectorError(DynaLabError):
|
|
"""A connector endpoint or registry operation failed."""
|
|
|
|
|
|
class JsonServerError(DynaLabError):
|
|
"""The JSON protocol server cannot perform the requested operation."""
|
|
|
|
|
|
__all__ = [
|
|
"ConnectorError",
|
|
"CoreError",
|
|
"DLPakError",
|
|
"DeriveError",
|
|
"DynaLabError",
|
|
"JsonServerError",
|
|
"PlaybackError",
|
|
]
|