Coverage for lynceus/lynceus_exceptions.py: 91%
11 statements
« prev ^ index » next coverage.py v7.10.0, created at 2025-07-29 08:46 +0000
« prev ^ index » next coverage.py v7.10.0, created at 2025-07-29 08:46 +0000
1from lynceus.utils import format_exception_human_readable
4class LynceusError(Exception):
5 """Base Lynceus exception, all specific exceptions inherits from it."""
7 def __init__(self, message, from_exception: Exception | None = None):
8 """
9 Initialize a LynceusError with a message and optional cause.
11 Args:
12 message: The error message
13 from_exception: Optional exception that caused this error
14 """
15 super().__init__()
16 self.__message = message
17 if from_exception:
18 self.__message += f"; caused by {format_exception_human_readable(from_exception, quote_message=True)}."
20 def __str__(self):
21 """
22 Return the error message as a string.
24 Returns:
25 str: The formatted error message
26 """
27 return self.__message
30class LynceusConfigError(LynceusError):
31 """Exception raised for configuration-related errors."""
34class LynceusFileError(LynceusError):
35 """Exception raised for file operation errors."""