diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-05-27 14:05:20 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-29 10:17:14 +0100 |
commit | 346ef9245db8423796cb3e0675ea82fd973d80f1 (patch) | |
tree | 406f522b85957d9f6366182fa602edb6f8cf82a3 /scripts/lib/wic | |
parent | 9761becc7f0a0d30198f4ee2b870ff1cb7b8f09f (diff) | |
download | poky-346ef9245db8423796cb3e0675ea82fd973d80f1.tar.gz |
wic: refactored processing of wic exceptions
All wic exceptions are now inherited from new base exception
class WicError. It makes them easy to maintain and catch.
Processing of exceptions is done this way:
Known wic exceptions cause wic to print error message to stdout.
Unknown exceptions are not catched anymore and produce standard
python traceback.
(From OE-Core rev: e5e2c18ce4344c14d9e52ece916333bd0a619281)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r-- | scripts/lib/wic/utils/errors.py | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/scripts/lib/wic/utils/errors.py b/scripts/lib/wic/utils/errors.py index 9410311875..d1b514dd9d 100644 --- a/scripts/lib/wic/utils/errors.py +++ b/scripts/lib/wic/utils/errors.py | |||
@@ -16,32 +16,14 @@ | |||
16 | # with this program; if not, write to the Free Software Foundation, Inc., 59 | 16 | # with this program; if not, write to the Free Software Foundation, Inc., 59 |
17 | # Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | # Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | class CreatorError(Exception): | 19 | class WicError(Exception): |
20 | """An exception base class for all imgcreate errors.""" | 20 | pass |
21 | keyword = '<creator>' | ||
22 | 21 | ||
23 | def __init__(self, msg): | 22 | class CreatorError(WicError): |
24 | self.msg = msg | 23 | pass |
25 | 24 | ||
26 | def __str__(self): | 25 | class Usage(WicError): |
27 | if isinstance(self.msg, unicode): | 26 | pass |
28 | self.msg = self.msg.encode('utf-8', 'ignore') | ||
29 | else: | ||
30 | self.msg = str(self.msg) | ||
31 | return self.keyword + self.msg | ||
32 | 27 | ||
33 | class Usage(CreatorError): | 28 | class ImageError(WicError): |
34 | keyword = '<usage>' | 29 | pass |
35 | |||
36 | def __str__(self): | ||
37 | if isinstance(self.msg, unicode): | ||
38 | self.msg = self.msg.encode('utf-8', 'ignore') | ||
39 | else: | ||
40 | self.msg = str(self.msg) | ||
41 | return self.keyword + self.msg + ', please use "--help" for more info' | ||
42 | |||
43 | class KsError(CreatorError): | ||
44 | keyword = '<kickstart>' | ||
45 | |||
46 | class ImageError(CreatorError): | ||
47 | keyword = '<mount>' | ||