Skip to content

trestle.common.err

trestle.common.err ¤

Trestle core errors module.

Classes¤

TrestleError ¤

Bases: RuntimeError

General framework (non-application) related errors.

Attributes:

Name Type Description
msg str

Human readable string describing the exception.

Source code in trestle/common/err.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class TrestleError(RuntimeError):
    """
    General framework (non-application) related errors.

    Attributes:
        msg (str): Human readable string describing the exception.
    """

    def __init__(self, msg: str):
        """Intialization for TresleError.

        Args:
            msg (str): The error message
        """
        RuntimeError.__init__(self)
        self.msg = msg

    def __str__(self) -> str:
        """Return Trestle error message if asked for a string."""
        return self.msg
Attributes¤
msg = msg instance-attribute ¤
Functions¤
__init__(msg) ¤

Intialization for TresleError.

Parameters:

Name Type Description Default
msg str

The error message

required
Source code in trestle/common/err.py
31
32
33
34
35
36
37
38
def __init__(self, msg: str):
    """Intialization for TresleError.

    Args:
        msg (str): The error message
    """
    RuntimeError.__init__(self)
    self.msg = msg
__str__() ¤

Return Trestle error message if asked for a string.

Source code in trestle/common/err.py
40
41
42
def __str__(self) -> str:
    """Return Trestle error message if asked for a string."""
    return self.msg

TrestleIncorrectArgsError ¤

Bases: TrestleError

General error for incorrect args passed to Trestle command.

Source code in trestle/common/err.py
76
77
78
79
80
81
82
83
84
85
86
class TrestleIncorrectArgsError(TrestleError):
    """General error for incorrect args passed to Trestle command."""

    def __init__(self, msg: str):
        """
        Initialize TrestleIncorrectArgsError.

        Args:
            msg (str): The error message
        """
        super().__init__(msg)
Functions¤
__init__(msg) ¤

Initialize TrestleIncorrectArgsError.

Parameters:

Name Type Description Default
msg str

The error message

required
Source code in trestle/common/err.py
79
80
81
82
83
84
85
86
def __init__(self, msg: str):
    """
    Initialize TrestleIncorrectArgsError.

    Args:
        msg (str): The error message
    """
    super().__init__(msg)

TrestleNotFoundError ¤

Bases: TrestleError

General framework related not found error.

Attributes:

Name Type Description
msg str

Human readable string describing the exception.

Source code in trestle/common/err.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class TrestleNotFoundError(TrestleError):
    """
    General framework related not found error.

    Attributes:
        msg (str): Human readable string describing the exception.
    """

    def __init__(self, msg: str):
        """
        Intialize TresleNotFoundError.

        Args:
            msg: The error message
        """
        super().__init__(msg)
Functions¤
__init__(msg) ¤

Intialize TresleNotFoundError.

Parameters:

Name Type Description Default
msg str

The error message

required
Source code in trestle/common/err.py
53
54
55
56
57
58
59
60
def __init__(self, msg: str):
    """
    Intialize TresleNotFoundError.

    Args:
        msg: The error message
    """
    super().__init__(msg)

TrestleRootError ¤

Bases: TrestleError

General error for trestle workspace root/setup errors.

Source code in trestle/common/err.py
63
64
65
66
67
68
69
70
71
72
73
class TrestleRootError(TrestleError):
    """General error for trestle workspace root/setup errors."""

    def __init__(self, msg: str):
        """
        Initialize TrestleRootError.

        Args:
            msg (str): The error message
        """
        super().__init__(msg)
Functions¤
__init__(msg) ¤

Initialize TrestleRootError.

Parameters:

Name Type Description Default
msg str

The error message

required
Source code in trestle/common/err.py
66
67
68
69
70
71
72
73
def __init__(self, msg: str):
    """
    Initialize TrestleRootError.

    Args:
        msg (str): The error message
    """
    super().__init__(msg)

Functions¤

handle_generic_command_exception(exception, logger, msg='Exception occured during execution') ¤

Print out error message based on the verbosity and return appropriate status code.

Source code in trestle/common/err.py
89
90
91
92
93
94
95
96
97
98
def handle_generic_command_exception(
    exception: Exception, logger: Logger, msg: str = 'Exception occured during execution'
) -> int:
    """Print out error message based on the verbosity and return appropriate status code."""
    if get_current_verbosity_level(logger) == 0:
        logger.error(msg + f': {exception}')
    else:
        logger.exception(msg + f': {exception}')

    return _exception_to_error_code(exception)

handler: python