from __future__ import annotations
[docs]
class OnyoCLIExitCode(Exception):
r"""Raise if the Onyo CLI should exit with a specific value."""
[docs]
def __init__(self,
message: str,
returncode: int):
r"""Instantiate an ``OnyoCLIExitCode`` with a message and exit code.
Parameters
----------
message
The exception message
returncode
The code to exit the command as.
"""
self.message = message
self.returncode = returncode
[docs]
class OnyoRepoError(Exception):
r"""Raise if something is wrong with an Onyo repository."""
[docs]
class OnyoInvalidRepoError(OnyoRepoError):
r"""Raise if the repository is invalid."""
[docs]
class OnyoProtectedPathError(Exception):
r"""Raise if path is protected.
For example: ``.git/``, :py:data:`onyo.lib.consts.ANCHOR_FILE_NAME`,
:py:data:`onyo.lib.consts.ONYO_DIR`, etc.
"""
[docs]
class OnyoInvalidFilterError(Exception):
r"""Raise if filters are invalidly defined."""
[docs]
class InvalidArgumentError(Exception):
r"""Raise if a (CLI-) command is invalidly called beyond what's covered by argparse."""
[docs]
class InvalidAssetError(Exception):
r"""Raise if an asset is invalid."""
[docs]
class InventoryOperationError(Exception):
r"""Raise if an inventory operation cannot be executed."""
[docs]
class InvalidInventoryOperationError(InventoryOperationError):
r"""Raise if an invalid inventory operation is requested."""
[docs]
class InventoryDirNotEmpty(InvalidInventoryOperationError):
r"""Raise if an inventory directory is not empty but needs to be in order to perform an operation."""
[docs]
class PendingInventoryOperationError(InventoryOperationError):
r"""Raise if there are unexpected pending operations."""
# TODO -> enhance message w/ hint to Inventory.reset/commit?
# would be useful in python context only
[docs]
class NoopError(InventoryOperationError):
r"""Raise if a requested operation is a no-op.
Signal that an inventory operation would not result in a change, allowing
callers to determine the failure paradigm: state (already-fine; success) vs
task (can't-do; failure).
"""
[docs]
class NotAnAssetError(Exception):
r"""Raise if an object is expected to be an asset but is not."""
[docs]
class NotADirError(Exception):
r"""Raise if an object is expected to be a directory but is not."""