Skip to content

Commit

Permalink
Add custom exceptions for CobblerTftp
Browse files Browse the repository at this point in the history
  • Loading branch information
SchoolGuy committed Jun 14, 2023
1 parent cd90b5f commit 73fa5ed
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cobbler_tftp/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
25 changes: 25 additions & 0 deletions src/cobbler_tftp/exceptions/settings_exceptions.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 73fa5ed

Please sign in to comment.