forked from softlayer/softlayer-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
38 lines (26 loc) · 1.02 KB
/
exceptions.py
File metadata and controls
38 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
SoftLayer.CLI.exceptions
~~~~~~~~~~~~~~~~~~~~~~~~
Exceptions to be used in the CLI modules.
:license: MIT, see LICENSE for more details.
"""
# pylint: disable=keyword-arg-before-vararg
class CLIHalt(SystemExit):
"""Smoothly halt the execution of the command. No error."""
def __init__(self, code=0, *args):
super(CLIHalt, self).__init__(*args)
self.code = code
def __str__(self):
return "<CLIHalt code=%s msg=%s>" % (self.code,
getattr(self, 'message'))
__repr__ = __str__
class CLIAbort(CLIHalt):
"""Halt the execution of the command. Gives an exit code of 2."""
def __init__(self, msg, *args):
super(CLIAbort, self).__init__(code=2, *args)
self.message = msg
class ArgumentError(CLIAbort):
"""Halt the execution of the command because of invalid arguments."""
def __init__(self, msg, *args):
super(ArgumentError, self).__init__(msg, *args)
self.message = "Argument Error: %s" % msg