From patchwork Wed Jan 11 18:30:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [bitbake-devel, 2/4] bitbake: improve error formatting for fetcher errors Date: Wed, 11 Jan 2012 18:30:49 -0000 From: Paul Eggleton X-Patchwork-Id: 19093 Message-Id: <120abd1529873c02b990f9ea002fe7651ea5285c.1326306561.git.paul.eggleton@linux.intel.com> To: bitbake-devel@lists.openembedded.org * 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. Signed-off-by: Paul Eggleton --- bitbake/lib/bb/build.py | 2 +- bitbake/lib/bb/fetch2/__init__.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index aabc1b6..30e5497 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py @@ -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" diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 3af56e5..b76358d 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -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)