Adds constructor for InvalidInputError
This change allows keyword arguments to constructor of InvalidInputError exception. And supports the use of ``reason`` as well as user-defined arguments as part of the error message. Closes-bug: #1546878 Co-Authored-By: Debayan Ray <debayan.ray@gmail.com> Change-Id: I99d901b58e45a90be128f1006a447ce69ebe91a1
This commit is contained in:
@@ -24,6 +24,21 @@ class InvalidInputError(Exception):
|
||||
|
||||
message = "Invalid Input: %(reason)s"
|
||||
|
||||
# Note(deray): Not mandating the user to provide the ``reason`` attribute
|
||||
# parameter while raising InvalidInputError exception. This is because of
|
||||
# backward-compatibility reasons. See its unit test file to know about its
|
||||
# different ways of usage.
|
||||
def __init__(self, message=None, **kwargs):
|
||||
|
||||
if not message:
|
||||
message = self.message
|
||||
|
||||
if 'reason' not in kwargs:
|
||||
kwargs['reason'] = 'Unknown'
|
||||
|
||||
message = message % kwargs
|
||||
super(InvalidInputError, self).__init__(message)
|
||||
|
||||
|
||||
class IloError(ProliantUtilsException):
|
||||
"""Base Exception.
|
||||
|
||||
Reference in New Issue
Block a user