pipetex.exceptions
Exception classes wich are used by the operations.
@author: Max Weise created: 25.07.2022
1""" Exception classes wich are used by the operations. 2 3@author: Max Weise 4created: 25.07.2022 5""" 6 7from pipetex.enums import SeverityLevels 8 9from typing import Optional 10 11 12class InternalException(Exception): 13 """Is raised when an operation needs to communicate an error. 14 15 This exception type is used when a runing operation can't execute properly 16 due to an internal error. This can be e.g. a missing file, an unsucessfull 17 call to a sys command or similar. Every instance of this error type must 18 contain a message and severity level. The message is used for logging and 19 the severity level will be used to determine if the pipeline needs to stop 20 or if it can still function. Each operation os responisble for giving an 21 appropriate message and severitylevel. 22 23 24 Args: 25 messgage: Exception message. Used to comunicate error to the user 26 and to log statement. 27 severity_level: Defines 'how bad' the error is and the further 28 error handling strategy. 29 error_tpye (optional): The type of error that is the cause of this 30 exception. 31 """ 32 33 # Public attributes 34 message: str 35 error_tpye: Optional[Exception] 36 37 # Private attributes 38 _severity_level: SeverityLevels 39 40 def __init__(self, message: str, severity_level: SeverityLevels, 41 error_tpye: Optional[Exception] = None): 42 """Instantiates an InternalException object. 43 44 Args: 45 messgage: Exception message. Used to comunicate error to the user 46 and to log statement. 47 severity_level: Defines 'how bad' the error is and the further 48 error handling strategy. 49 error_tpye (optional): The type of error that is the cause of this 50 exception. 51 """ 52 53 self.message = message 54 self._severity_level = severity_level 55 self.error_tpye = error_tpye 56 57 @property 58 def severity_level(self) -> int: 59 """The severity level represented by an integer value.""" 60 return self._severity_level.value 61 62 def __str__(self) -> str: 63 """String representation of the exception type.""" 64 _errorType = ("InternalException" if not self.error_tpye 65 else self.error_tpye) 66 return f"{_errorType} ({self.severity_level}) | {self.message}" 67 68 def __repr__(self) -> str: 69 """Repr method of the class. For now just use the super method.""" 70 return super().__repr__() 71 72 # === Define order and comparison operations === 73 def __eq__(self, other) -> bool: 74 """Overloads the == operator""" 75 return bool(self.severity_level == other.severity_level) 76 77 def __ge__(self, other) -> bool: 78 """Overloads the >= operator""" 79 return bool(self.severity_level >= other.severity_level) 80 81 def __le__(self, other) -> bool: 82 """Overloads the <= operator.""" 83 return bool(self.severity_level <= other.severity_level) 84 85 def __lt__(self, other) -> bool: 86 """Overloads the < operator.""" 87 return bool(self.severity_level < other.severity_level)
class
InternalException(builtins.Exception):
13class InternalException(Exception): 14 """Is raised when an operation needs to communicate an error. 15 16 This exception type is used when a runing operation can't execute properly 17 due to an internal error. This can be e.g. a missing file, an unsucessfull 18 call to a sys command or similar. Every instance of this error type must 19 contain a message and severity level. The message is used for logging and 20 the severity level will be used to determine if the pipeline needs to stop 21 or if it can still function. Each operation os responisble for giving an 22 appropriate message and severitylevel. 23 24 25 Args: 26 messgage: Exception message. Used to comunicate error to the user 27 and to log statement. 28 severity_level: Defines 'how bad' the error is and the further 29 error handling strategy. 30 error_tpye (optional): The type of error that is the cause of this 31 exception. 32 """ 33 34 # Public attributes 35 message: str 36 error_tpye: Optional[Exception] 37 38 # Private attributes 39 _severity_level: SeverityLevels 40 41 def __init__(self, message: str, severity_level: SeverityLevels, 42 error_tpye: Optional[Exception] = None): 43 """Instantiates an InternalException object. 44 45 Args: 46 messgage: Exception message. Used to comunicate error to the user 47 and to log statement. 48 severity_level: Defines 'how bad' the error is and the further 49 error handling strategy. 50 error_tpye (optional): The type of error that is the cause of this 51 exception. 52 """ 53 54 self.message = message 55 self._severity_level = severity_level 56 self.error_tpye = error_tpye 57 58 @property 59 def severity_level(self) -> int: 60 """The severity level represented by an integer value.""" 61 return self._severity_level.value 62 63 def __str__(self) -> str: 64 """String representation of the exception type.""" 65 _errorType = ("InternalException" if not self.error_tpye 66 else self.error_tpye) 67 return f"{_errorType} ({self.severity_level}) | {self.message}" 68 69 def __repr__(self) -> str: 70 """Repr method of the class. For now just use the super method.""" 71 return super().__repr__() 72 73 # === Define order and comparison operations === 74 def __eq__(self, other) -> bool: 75 """Overloads the == operator""" 76 return bool(self.severity_level == other.severity_level) 77 78 def __ge__(self, other) -> bool: 79 """Overloads the >= operator""" 80 return bool(self.severity_level >= other.severity_level) 81 82 def __le__(self, other) -> bool: 83 """Overloads the <= operator.""" 84 return bool(self.severity_level <= other.severity_level) 85 86 def __lt__(self, other) -> bool: 87 """Overloads the < operator.""" 88 return bool(self.severity_level < other.severity_level)
Is raised when an operation needs to communicate an error.
This exception type is used when a runing operation can't execute properly due to an internal error. This can be e.g. a missing file, an unsucessfull call to a sys command or similar. Every instance of this error type must contain a message and severity level. The message is used for logging and the severity level will be used to determine if the pipeline needs to stop or if it can still function. Each operation os responisble for giving an appropriate message and severitylevel.
Args
- messgage: Exception message. Used to comunicate error to the user and to log statement.
- severity_level: Defines 'how bad' the error is and the further error handling strategy.
- error_tpye (optional): The type of error that is the cause of this exception.
InternalException( message: str, severity_level: pipetex.enums.SeverityLevels, error_tpye: Optional[Exception] = None)
41 def __init__(self, message: str, severity_level: SeverityLevels, 42 error_tpye: Optional[Exception] = None): 43 """Instantiates an InternalException object. 44 45 Args: 46 messgage: Exception message. Used to comunicate error to the user 47 and to log statement. 48 severity_level: Defines 'how bad' the error is and the further 49 error handling strategy. 50 error_tpye (optional): The type of error that is the cause of this 51 exception. 52 """ 53 54 self.message = message 55 self._severity_level = severity_level 56 self.error_tpye = error_tpye
Instantiates an InternalException object.
Args
- messgage: Exception message. Used to comunicate error to the user and to log statement.
- severity_level: Defines 'how bad' the error is and the further error handling strategy.
- error_tpye (optional): The type of error that is the cause of this exception.
Inherited Members
- builtins.BaseException
- with_traceback
- args