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:
kesper
2016-06-13 11:24:05 +05:30
committed by Debayan Ray
parent 4845cf77b2
commit 32a1cc26f8
2 changed files with 82 additions and 0 deletions

View File

@@ -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.