summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/wic/utils/errors.py34
-rwxr-xr-xscripts/wic11
2 files changed, 13 insertions, 32 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
19class CreatorError(Exception): 19class WicError(Exception):
20 """An exception base class for all imgcreate errors.""" 20 pass
21 keyword = '<creator>'
22 21
23 def __init__(self, msg): 22class CreatorError(WicError):
24 self.msg = msg 23 pass
25 24
26 def __str__(self): 25class 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
33class Usage(CreatorError): 28class 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
43class KsError(CreatorError):
44 keyword = '<kickstart>'
45
46class ImageError(CreatorError):
47 keyword = '<mount>'
diff --git a/scripts/wic b/scripts/wic
index 90b36c68ac..cf968591e2 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -53,6 +53,7 @@ else:
53 bitbake_main = None 53 bitbake_main = None
54 54
55from wic.utils.oe.misc import find_bitbake_env_lines, set_bitbake_env_lines 55from wic.utils.oe.misc import find_bitbake_env_lines, set_bitbake_env_lines
56from wic.utils.errors import WicError
56from image import engine 57from image import engine
57from image import help as hlp 58from image import help as hlp
58 59
@@ -309,10 +310,8 @@ def main(argv):
309 310
310if __name__ == "__main__": 311if __name__ == "__main__":
311 try: 312 try:
312 ret = main(sys.argv[1:]) 313 sys.exit(main(sys.argv[1:]))
313 except Exception: 314 except WicError as err:
314 ret = 1 315 print >> sys.stderr, "ERROR:", err
315 import traceback 316 sys.exit(1)
316 traceback.print_exc()
317 sys.exit(ret)
318 317