Keep error info from exception URLGrabError.
authorHuang Hao <hao.h.huang@intel.com>
Thu, 28 Feb 2013 03:37:19 +0000 (11:37 +0800)
committerGerrit Code Review <gerrit2@otctools.jf.intel.com>
Thu, 28 Feb 2013 06:59:12 +0000 (22:59 -0800)
The origianl URLGrabError exception contains useful information
describing detail of the error, such as errno and http error
code.

However in some situation it doesn't include url address. So append
it if not appear.

Examples of console output before:
    Error <creator>: URLGrabber error: https://xxxx
    Error <creator>: URLGrabber error: https://xxxx

We can't find out difference from those two message.
After:
    Error <creator>: [Errno 14] HTTP Error 401 : https://xxxx
    Error <creator>: [Errno 14] problem making ssl connection on https://xxxx

Change-Id: I3f153e4caf8bbfcbac56ca22118733de7c5a3e66

mic/utils/grabber.py

index cf2fe09..45e30b4 100644 (file)
@@ -35,12 +35,19 @@ def myurlgrab(url, filename, proxies, progress_obj = None):
 
     else:
         try:
-            filename = g.urlgrab(url = str(url), filename = filename,
-                ssl_verify_host = False, ssl_verify_peer = False,
-                proxies = proxies, http_headers = (('Pragma', 'no-cache'),),
-                quote = 0, progress_obj = progress_obj)
-        except grabber.URLGrabError, e:
-            raise CreatorError("URLGrabber error: %s" % url)
+            filename = g.urlgrab(url=str(url),
+                                 filename=filename,
+                                 ssl_verify_host=False,
+                                 ssl_verify_peer=False,
+                                 proxies=proxies,
+                                 http_headers=(('Pragma', 'no-cache'),),
+                                 quote=0,
+                                 progress_obj=progress_obj)
+        except grabber.URLGrabError, err:
+            msg = str(err)
+            if msg.find(url) < 0:
+                msg += ' on %s' % url
+            raise CreatorError(msg)
 
     return filename