-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom exceptions for CobblerTftp
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |