]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: lib/bb/data.py: improve output for expansion errors
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Tue, 25 Sep 2012 14:17:17 +0000 (15:17 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 27 Sep 2012 15:45:28 +0000 (16:45 +0100)
Instead of logging the function/variable separately as a NOTE when
failing to expand, re-raise ExpansionError with more contextual
information. This means that the full details are reported in Hob as
well as actually reporting the original error message in any UI where
we previously did not. For example, we used to get this with tab/space
indentation issues in a python function:

NOTE: Error expanding variable populate_packages
ERROR: Unable to parse /path/to/recipename.bb

Now, we will get this:

ERROR: ExpansionError during parsing /path/to/recipename.bb: Failure
 expanding variable populate_packages: IndentationError: unindent does
 not match any outer indentation level (<string>, line 4)

Fixes [YOCTO #3162].

(Bitbake rev: ce5c7a95a359cdaecab7c4a519ad4f9df029da82)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/data.py
bitbake/lib/bb/data_smart.py

index 5b7a092a21bc54a17c63bb21bed09a3086973b07..9a32353d682e2da221b6e7fee781e7a225885ef1 100644 (file)
@@ -323,9 +323,8 @@ def build_dependencies(key, keys, shelldeps, vardepvals, d):
 
         deps |= set((vardeps or "").split())
         deps -= set((d.getVarFlag(key, "vardepsexclude", True) or "").split())
-    except:
-        bb.note("Error expanding variable %s" % key)
-        raise
+    except Exception as e:
+        raise bb.data_smart.ExpansionError(key, None, e)
     return deps, value
     #bb.note("Variable %s references %s and calls %s" % (key, str(deps), str(execs)))
     #d.setVarFlag(key, "vardeps", deps)
index f5f3b13a738ed1ec796f89c2b0e3f79b24ab099a..ec3c04e30c885e53252edd11a7285e02c52dfa32 100644 (file)
@@ -103,7 +103,10 @@ class ExpansionError(Exception):
         self.variablename = varname
         self.exception = exception
         if varname:
-            self.msg = "Failure expanding variable %s, expression was %s which triggered exception %s: %s" % (varname, expression, type(exception).__name__, exception)
+            if expression:
+                self.msg = "Failure expanding variable %s, expression was %s which triggered exception %s: %s" % (varname, expression, type(exception).__name__, exception)
+            else:
+                self.msg = "Failure expanding variable %s: %s: %s" % (varname, type(exception).__name__, exception)
         else:
             self.msg = "Failure expanding expression %s which triggered exception %s: %s" % (expression, type(exception).__name__, exception)
         Exception.__init__(self, self.msg)