summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-23 13:13:31 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-24 21:38:41 +0000
commit1265ce98d7a2ab024e639647ac6300c3cf808730 (patch)
treec1e5bdc9d94577379acf533dfd7e928882709941
parent99c38e8e31adf02a1945f54fe47dd1ac7941cb21 (diff)
downloadbitbake-1265ce98d7a2ab024e639647ac6300c3cf808730.tar.gz
bitbake/data_smart: Improve Variable expansion error handling
If expanding a variable triggers an exception the caller currently has no way to supress the error message or otherwise handle the siutation. An example of where this is a problem is "bitbake -e" showing tracebacks and errors for variables like SRCPV in OE/Poky. Secondly in a chained expansion fails, log mesages are recorded for every step of the expansion, not just the innermost error which is where the real failure occured. To fix this we introduce a new exception ExpansionError which callers can handle as appropriate. (From Poky rev: 101b599110f7bc29f52a14a968f30323aeb797ca) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/data_smart.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index e76fbbf6c..df9798ad5 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -90,6 +90,17 @@ class DataContext(dict):
else:
return value
+class ExpansionError(Exception):
+ def __init__(self, varname, expression, exception):
+ self.expression = expression
+ self.variablename = varname
+ self.exception = exception
+ self.msg = "Failure expanding variable %s, expression was %s which triggered exception %s: %s" % (varname, expression, type(exception).__name__, exception)
+ Exception.__init__(self, self.msg)
+ self.args = (varname, expression, exception)
+ def __str__(self):
+ return self.msg
+
class DataSmart(MutableMapping):
def __init__(self, special = COWDictBase.copy(), seen = COWDictBase.copy() ):
self.dict = {}
@@ -117,9 +128,10 @@ class DataSmart(MutableMapping):
s = __expand_python_regexp__.sub(varparse.python_sub, s)
if s == olds:
break
- except Exception:
- logger.exception("Error evaluating '%s'", s)
+ except ExpansionError:
raise
+ except Exception as exc:
+ raise ExpansionError(varname, s, exc)
varparse.value = s