Skip to contentSkip to conversation

Minor improvements to error messages

PATCH In review Paul Eggleton 1 participant 6 messages Jan 11, 2012 – Jan 12, 2012

lore
Share & tools
lore
#0 lore raw

cover Minor improvements to error messages

A few minor improvements to error output. I'm still working on some deeper improvements but these are ready to go in immediately.

The patches (against Poky, but apply cleanly with -p2 against bitbake master) are available in the git repository at:
git://git.yoctoproject.org/poky-contrib paule/errorhandling1
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/errorhandling1

Paul Eggleton (4):
bitbake/knotty: don't count errors as warnings
bitbake: improve error formatting for fetcher errors
bitbake: make warning for initial fetch failure one line bitbake/runqueue: avoid "failed" in task summary if nothing did

 bitbake/lib/bb/build.py           |    2 +-
 bitbake/lib/bb/fetch2/__init__.py |   10 +++++++---
 bitbake/lib/bb/runqueue.py        |    6 +++++-
 bitbake/lib/bb/ui/knotty.py       |    2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/4 bitbake/knotty: don't count errors as warnings

The count of warnings being shown at the end also included the number of errors.

---
 bitbake/lib/bb/ui/knotty.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
bitbake/lib/bb/ui/knotty.py +1 -1
index 0340619..cd6e0e7 100644
@@ -127,7 +127,7 @@ def main(server, eventHandler):
                 if event.levelno >= format.ERROR:
                     errors = errors + 1
                     return_value = 1
-                if event.levelno >= format.WARNING:
+                elif event.levelno >= format.WARNING:
                     warnings = warnings + 1
                 # For "normal" logging conditions, don't show note logs from tasks
                 # but do show them if the user has changed the default log level to 
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/4 bitbake: improve error formatting for fetcher errors

In reply to Paul Eggleton

* The "name" argument to FuncFailed is rarely used as a name in actual usage within bitbake, so don't treat it as one in the output.
* Don't print URL for FetchError if it was not specified (i.e. don't output "Fetcher failure for URL 'None'")
* Don't include URL in "unable to fetch from any source" message since we supply it to FetchError and it will be printed anyway.

---
 bitbake/lib/bb/build.py           |    2 +-
 bitbake/lib/bb/fetch2/__init__.py |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
bitbake/lib/bb/build.py +1 -1
index aabc1b6..30e5497 100644
@@ -53,7 +53,7 @@ class FuncFailed(Exception):
         self.logfile = logfile
         self.name = name
         if name:
-            self.msg = "Function '%s' failed" % name
+            self.msg = 'Function failed: %s' % name
         else:
             self.msg = "Function failed"
 
bitbake/lib/bb/fetch2/__init__.py +5 -2
index 3af56e5..b76358d 100644
@@ -55,7 +55,10 @@ class MalformedUrl(BBFetchException):
 class FetchError(BBFetchException):
     """General fetcher exception when something happens incorrectly"""
     def __init__(self, message, url = None):
-         msg = "Fetcher failure for URL: '%s'. %s" % (url, message)
+         if url:
+            msg = "Fetcher failure for URL: '%s'. %s" % (url, message)
+         else:
+            msg = "Fetcher failure: %s" % message
          self.url = url
          BBFetchException.__init__(self, msg)
          self.args = (message, url)
@@ -983,7 +986,7 @@ class Fetch(object):
                         localpath = try_mirrors (self.d, ud, mirrors)
 
                 if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1):
-                    raise FetchError("Unable to fetch URL %s from any source." % u, u)
+                    raise FetchError("Unable to fetch URL from any source.", u)
 
                 update_stamp(u, ud, self.d)
 
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/4 bitbake: make warning for initial fetch failure one line

In reply to Paul Eggleton

Instead of printing the full fetch command and output for the initial fetch failure, just print a one-liner containing the URL. If the user needs more detail the full version is still output as a debug message which will go into the log.

---
 bitbake/lib/bb/fetch2/__init__.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +2 -1
index b76358d..80cef3f 100644
@@ -977,7 +977,8 @@ class Fetch(object):
                         raise
 
                     except BBFetchException as e:
-                        logger.warn(str(e))
+                        logger.warn('Failed to fetch URL %s' % u)
+                        logger.debug(1, str(e))
                         # Remove any incomplete fetch
                         if os.path.isfile(ud.localpath):
                             bb.utils.remove(ud.localpath)
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH 4/4 bitbake/runqueue: avoid "failed" in task summary if nothing did

In reply to Paul Eggleton

Seeing the word "failed" alone without reading the whole context has occasionally triggered an automatic assumption on the part of some users (myself included) that something has gone wrong, even when this message is telling you that "0 [tasks] failed". To avoid this let's just say "all succeeded" in this case instead.

As a bonus this means you can now search the output for "fail" and not find anything if all went well.

---
 bitbake/lib/bb/runqueue.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
bitbake/lib/bb/runqueue.py +5 -1
index 86744fb..054d36c 100644
@@ -968,7 +968,11 @@ class RunQueue:
 
         if self.state is runQueueComplete:
             # All done
-            logger.info("Tasks Summary: Attempted %d tasks of which %d didn't need to be rerun and %d failed.", self.rqexe.stats.completed, self.rqexe.stats.skipped, self.rqexe.stats.failed)
+            if self.rqexe.stats.failed:
+                logger.info("Tasks Summary: Attempted %d tasks of which %d didn't need to be rerun and %d failed.", self.rqexe.stats.completed, self.rqexe.stats.skipped, self.rqexe.stats.failed)
+            else:
+                # Let's avoid the word "failed" if nothing actually did
+                logger.info("Tasks Summary: Attempted %d tasks of which %d didn't need to be rerun and all succeeded.", self.rqexe.stats.completed, self.rqexe.stats.skipped)
             return False
 
         if self.state is runQueueChildProcess:
Signature · 1 line
1.7.5.4
#5 lore raw
In reply to Paul Eggleton
Quoted 2 lines · On Wednesday 11 January 2012 18:30:47 Paul Eggleton wrote:

A few minor improvements to error output. I'm still working on some deeper improvements but these are ready to go in immediately.

Spoke a little too soon, I'd prefer to merge one of these patches into another I've been working on so please ignore this series.

Thanks,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre