diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-08 18:16:00 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-09 14:06:52 +0100 |
commit | a189ec4ae74022fddfb5e1b13c4747bb891e3c6b (patch) | |
tree | 65d4700aa1a8fa6894c2cee9e7793b64ba0c8b17 /bitbake/lib/bb/utils.py | |
parent | bc95ddec6da0d2ae5da2637f2d065b89594ed041 (diff) | |
download | poky-a189ec4ae74022fddfb5e1b13c4747bb891e3c6b.tar.gz |
bitbake: utils: Improve better_compile error message
Similarly to the better_exec improvements, improve the compile failure
messages to be more user readable.
(Bitbake rev: 9bc92d0210e13e4cc98727f6c9ec2f47c2221e77)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 9d7a32fb25..462eb689b9 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -255,18 +255,20 @@ def better_compile(text, file, realfile, mode = "exec"): | |||
255 | try: | 255 | try: |
256 | return compile(text, file, mode) | 256 | return compile(text, file, mode) |
257 | except Exception as e: | 257 | except Exception as e: |
258 | error = [] | ||
258 | # split the text into lines again | 259 | # split the text into lines again |
259 | body = text.split('\n') | 260 | body = text.split('\n') |
260 | logger.error("Error in compiling python function in %s", realfile) | 261 | error.append("Error in compiling python function in %s:\n" % realfile) |
261 | logger.error(str(e)) | ||
262 | if e.lineno: | 262 | if e.lineno: |
263 | logger.error("The lines leading to this error were:") | 263 | error.append("The code lines resulting in this error were:") |
264 | logger.error("\t%d:%s:'%s'", e.lineno, e.__class__.__name__, body[e.lineno-1]) | 264 | error.extend(_print_trace(body, e.lineno)) |
265 | logger.error("\n".join(_print_trace(body, e.lineno))) | ||
266 | else: | 265 | else: |
267 | logger.error("The function causing this error was:") | 266 | error.append("The function causing this error was:") |
268 | for line in body: | 267 | for line in body: |
269 | logger.error(line) | 268 | error.append(line) |
269 | error.append("%s: %s" % (e.__class__.__name__, str(e))) | ||
270 | |||
271 | logger.error("\n".join(error)) | ||
270 | 272 | ||
271 | e = bb.BBHandledException(e) | 273 | e = bb.BBHandledException(e) |
272 | raise e | 274 | raise e |