Skip to content

err

trestle.common.err ¤

Trestle core errors module.

Classes¤

TrestleError (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
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
Methods¤
__init__(self, msg) special ¤

Intialization for TresleError.

Parameters:

Name Type Description Default
msg str

The error message

required
Source code in trestle/common/err.py
def __init__(self, msg: str):
    """Intialization for TresleError.

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

Return Trestle error message if asked for a string.

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

TrestleIncorrectArgsError (TrestleError) ¤

General error for incorrect args passed to Trestle command.

Source code in trestle/common/err.py
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)
Methods¤
__init__(self, msg) special ¤

Initialize TrestleIncorrectArgsError.

Parameters:

Name Type Description Default
msg str

The error message

required
Source code in trestle/common/err.py
def __init__(self, msg: str):
    """
    Initialize TrestleIncorrectArgsError.

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

TrestleNotFoundError (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
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)
Methods¤
__init__(self, msg) special ¤

Intialize TresleNotFoundError.

Parameters:

Name Type Description Default
msg str

The error message

required
Source code in trestle/common/err.py
def __init__(self, msg: str):
    """
    Intialize TresleNotFoundError.

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

TrestleRootError (TrestleError) ¤

General error for Trestle project root/setup errors.

Source code in trestle/common/err.py
class TrestleRootError(TrestleError):
    """General error for Trestle project root/setup errors."""

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

        Args:
            msg (str): The error message
        """
        super().__init__(msg)
Methods¤
__init__(self, msg) special ¤

Initialize TrestleRootError.

Parameters:

Name Type Description Default
msg str

The error message

required
Source code in trestle/common/err.py
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
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