|
@@ 153-186 (lines=34) @@
|
| 150 |
|
) |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
class RequiredArgument(GvmError): |
| 154 |
|
"""Raised if a required argument/parameter is missing |
| 155 |
|
|
| 156 |
|
Derives from :py:class:`GvmError` |
| 157 |
|
|
| 158 |
|
Arguments: |
| 159 |
|
message: Error message to be displayed. Takes precedence over argument |
| 160 |
|
and function. |
| 161 |
|
argument: Optional name of the required argument. |
| 162 |
|
function: Optional name of the called function. |
| 163 |
|
""" |
| 164 |
|
|
| 165 |
|
def __init__( |
| 166 |
|
self, |
| 167 |
|
message: Optional[str] = None, |
| 168 |
|
*, |
| 169 |
|
argument: Optional[str] = None, |
| 170 |
|
function: Optional[str] = None |
| 171 |
|
): |
| 172 |
|
# pylint: disable=super-init-not-called |
| 173 |
|
self.message = message |
| 174 |
|
self.argument = argument |
| 175 |
|
self.function = function |
| 176 |
|
|
| 177 |
|
def __str__(self): |
| 178 |
|
if self.message: |
| 179 |
|
return self.message |
| 180 |
|
|
| 181 |
|
if not self.function: |
| 182 |
|
return "Required argument {}".format(self.argument) |
| 183 |
|
|
| 184 |
|
if not self.argument: |
| 185 |
|
return "Required argument missing for {}".format(self.function) |
| 186 |
|
|
| 187 |
|
return "{} requires a {} argument".format(self.function, self.argument) |
| 188 |
|
|
|
@@ 83-117 (lines=35) @@
|
| 80 |
|
) |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
class InvalidArgument(GvmError): |
| 84 |
|
"""Raised if an invalid argument/parameter is passed |
| 85 |
|
|
| 86 |
|
Derives from :py:class:`GvmError` |
| 87 |
|
|
| 88 |
|
Arguments: |
| 89 |
|
message: Error message to be displayed. Takes precedence over argument |
| 90 |
|
and function |
| 91 |
|
argument: Optional name of the invalid argument |
| 92 |
|
function: Optional name of the called function |
| 93 |
|
""" |
| 94 |
|
|
| 95 |
|
def __init__( |
| 96 |
|
self, |
| 97 |
|
message: Optional[str] = None, |
| 98 |
|
*, |
| 99 |
|
argument: Optional[str] = None, |
| 100 |
|
function: Optional[str] = None |
| 101 |
|
): |
| 102 |
|
# pylint: disable=super-init-not-called |
| 103 |
|
self.message = message |
| 104 |
|
self.argument = argument |
| 105 |
|
self.function = function |
| 106 |
|
|
| 107 |
|
def __str__(self): |
| 108 |
|
if self.message: |
| 109 |
|
return self.message |
| 110 |
|
|
| 111 |
|
if not self.function: |
| 112 |
|
return "Invalid argument {}".format(self.argument) |
| 113 |
|
|
| 114 |
|
if not self.argument: |
| 115 |
|
return "Invalid argument for {}".format(self.function) |
| 116 |
|
|
| 117 |
|
return "Invalid argument {} for {}".format(self.argument, self.function) |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
class InvalidArgumentType(GvmError): |