aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-10-21 09:50:27 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 10:38:55 +0100
commite0284ab41f7a1889f28e719212df66e942959f4c (patch)
treedfbd27e96968c07d49372c6ed06f0b51f2c6c8b8 /tools
parent59cc901d3d15079b3666e5902b4c8b1a83ff1fd2 (diff)
Properly propagate parse errors
Replace all try/catch statements used when parsing with checks for engine->hasException. Change-Id: I4493cb600d5a3eb095c2003bb88bd031403e47c9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmljs/main.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/qmljs/main.cpp b/tools/qmljs/main.cpp
index 2d31dbfc0f..32a45d9289 100644
--- a/tools/qmljs/main.cpp
+++ b/tools/qmljs/main.cpp
@@ -202,22 +202,22 @@ int main(int argc, char *argv[])
const QString code = QString::fromUtf8(file.readAll());
file.close();
- try {
- QV4::Script script(ctx, code, fn);
- script.parseAsBinding = runAsQml;
- script.parse();
- QV4::ScopedValue result(scope, script.run());
- if (!result->isUndefined()) {
- if (! qgetenv("SHOW_EXIT_VALUE").isEmpty())
- std::cout << "exit value: " << qPrintable(result->toString(ctx)->toQString()) << std::endl;
- }
- } catch (...) {
+ QV4::ScopedValue result(scope);
+ QV4::Script script(ctx, code, fn);
+ script.parseAsBinding = runAsQml;
+ script.parse();
+ if (!scope.engine->hasException)
+ result = script.run();
+ if (scope.engine->hasException) {
QV4::StackTrace trace;
QV4::ScopedValue ex(scope, ctx->catchException(&trace));
showException(ctx, ex, trace);
return EXIT_FAILURE;
}
-
+ if (!result->isUndefined()) {
+ if (! qgetenv("SHOW_EXIT_VALUE").isEmpty())
+ std::cout << "exit value: " << qPrintable(result->toString(ctx)->toQString()) << std::endl;
+ }
} else {
std::cerr << "Error: cannot open file " << fn.toUtf8().constData() << std::endl;
return EXIT_FAILURE;