summaryrefslogtreecommitdiff
path: root/scripts/lib/wic/utils
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-05-27 14:05:20 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-27 17:44:44 +0100
commite5e2c18ce4344c14d9e52ece916333bd0a619281 (patch)
treeb6486e09ad5c9147508d01f919e3c93571288041 /scripts/lib/wic/utils
parentf9b121d8295eb9e297627f4d623164b43349a638 (diff)
downloadopenembedded-core-e5e2c18ce4344c14d9e52ece916333bd0a619281.tar.gz
openembedded-core-e5e2c18ce4344c14d9e52ece916333bd0a619281.tar.bz2
openembedded-core-e5e2c18ce4344c14d9e52ece916333bd0a619281.zip
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. 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/utils')
-rw-r--r--scripts/lib/wic/utils/errors.py34
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 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-class CreatorError(Exception):
- """An exception base class for all imgcreate errors."""
- keyword = '<creator>'
+class WicError(Exception):
+ pass
- def __init__(self, msg):
- self.msg = msg
+class CreatorError(WicError):
+ pass
- def __str__(self):
- if isinstance(self.msg, unicode):
- self.msg = self.msg.encode('utf-8', 'ignore')
- else:
- self.msg = str(self.msg)
- return self.keyword + self.msg
+class Usage(WicError):
+ pass
-class Usage(CreatorError):
- keyword = '<usage>'
-
- def __str__(self):
- if isinstance(self.msg, unicode):
- self.msg = self.msg.encode('utf-8', 'ignore')
- else:
- self.msg = str(self.msg)
- return self.keyword + self.msg + ', please use "--help" for more info'
-
-class KsError(CreatorError):
- keyword = '<kickstart>'
-
-class ImageError(CreatorError):
- keyword = '<mount>'
+class ImageError(WicError):
+ pass