Skip to content

errors.py

Error handling for tensor image pipeline.

This module implements error handling for configuration, registry and execution of the pipeline.

Copyright (C) 2025 Matti Kaupenjohann

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

BuilderError dataclass

Bases: RuntimeError

Source code in tipi/errors.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@dataclass
class BuilderError(RuntimeError):
    error_value: Any
    error_code: ErrorCode | None = None

    def __post_init__(self) -> None:
        pass

    def _set_error_code(self, error_code: ErrorCode) -> None:
        """Set the error code (called by subclasses)."""
        self.error_code = error_code

    def __str__(self) -> str:
        if self.error_code:
            return f"[{self.error_code.code}]: {self.error_code.message}: {self.error_value}"
        return f"BuilderError: {self.error_value}"

ConfigInvalidTomlError dataclass

Bases: BuilderError

Raised when the configuration file is not valid toml

Source code in tipi/errors.py
79
80
81
82
83
class ConfigInvalidTomlError(BuilderError):
    """Raised when the configuration file is not valid toml"""

    def __post_init__(self) -> None:
        self._set_error_code(ErrorCode.CONFIG_INVALID)

ConfigNotFoundError dataclass

Bases: BuilderError

Raised when the builder configuration file does not exists

Source code in tipi/errors.py
65
66
67
68
69
class ConfigNotFoundError(BuilderError):
    """Raised when the builder configuration file does not exists"""

    def __post_init__(self) -> None:
        self._set_error_code(ErrorCode.CONFIG_MISSING)

ConfigPermissionError dataclass

Bases: BuilderError

Raised when the builder configuration file does not exists

Source code in tipi/errors.py
72
73
74
75
76
class ConfigPermissionError(BuilderError):
    """Raised when the builder configuration file does not exists"""

    def __post_init__(self) -> None:
        self._set_error_code(ErrorCode.CONFIG_PERMISSION)

ConfigSectionError dataclass

Bases: BuilderError

Raised for config section missing

Source code in tipi/errors.py
86
87
88
89
90
class ConfigSectionError(BuilderError):
    """Raised for config section missing"""

    def __post_init__(self) -> None:
        self._set_error_code(ErrorCode.CONFIG_SECTION)

ExecutionError

Bases: Exception

Raised during process execution failures

Source code in tipi/errors.py
123
124
125
126
127
128
class ExecutionError(Exception):
    """Raised during process execution failures"""

    def __init__(self, process: str, error: Exception):
        error_code = ErrorCode.PROCESS_EXECUTION
        super().__init__(f"[{error_code.code}]: Process {process} failed with {error}")

InstTypeError dataclass

Bases: BuilderError

Raised when type in config not set

Source code in tipi/errors.py
115
116
117
118
119
class InstTypeError(BuilderError):
    """Raised when type in config not set"""

    def __post_init__(self) -> None:
        self._set_error_code(ErrorCode.INST_TYPE)

RegistryError dataclass

Bases: BuilderError

Raised for class registration issues

Source code in tipi/errors.py
101
102
103
104
105
class RegistryError(BuilderError):
    """Raised for class registration issues"""

    def __post_init__(self) -> None:
        self._set_error_code(ErrorCode.REGISTRY_INVALID)

RegistryParamError dataclass

Bases: BuilderError

Raised for class instatioation with wrong params

Source code in tipi/errors.py
108
109
110
111
112
class RegistryParamError(BuilderError):
    """Raised for class instatioation with wrong params"""

    def __post_init__(self) -> None:
        self._set_error_code(ErrorCode.REGISTRY_PARAM)