diff --git a/src/cobbler_tftp/exceptions/__init__.py b/src/cobbler_tftp/exceptions/__init__.py new file mode 100644 index 0000000..42e9956 --- /dev/null +++ b/src/cobbler_tftp/exceptions/__init__.py @@ -0,0 +1,9 @@ +"""Custom exceptions for cobbler-tftp.""" + + +class CobblerTftpException(Exception): + """Generic cobbler-tftp exception.""" + + def __init__(self, message: str = "CobblerTFTPException"): + """Create custom generic CobblerTFTPException.""" + super().__init__(message) diff --git a/src/cobbler_tftp/exceptions/settings_exceptions.py b/src/cobbler_tftp/exceptions/settings_exceptions.py new file mode 100644 index 0000000..a8652a6 --- /dev/null +++ b/src/cobbler_tftp/exceptions/settings_exceptions.py @@ -0,0 +1,25 @@ +"""Custom exceptions for cobbler-tftp's settings module.""" + + +class CobblerTftpSettingsException(Exception): + """Generic cobbler-tftp exception.""" + + def __init__(self, message: str = "An Error occured!"): + """Create custom generic settings exception.""" + super().__init__(message) + + +class CobblerTftpMissingConfigParameterException(KeyError): + """Exception to handle a missing but required config parameter.""" + + def __init__( + self, + message="MissingConfigParameterException: Application settings missing required parameter!", + parameter: str = "NONE", + ): + """Create custom exception to raise when a specific config parameter is missing for the application settings.""" + if parameter is None or parameter == "NONE": + raise ValueError("Parameter cannot be 'NONE'") + self.parameter = parameter + self.message = str.join(message, parameter) + super().__init__(message, parameter)