From e0284ab41f7a1889f28e719212df66e942959f4c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 21 Oct 2013 09:50:27 +0200 Subject: Properly propagate parse errors Replace all try/catch statements used when parsing with checks for engine->hasException. Change-Id: I4493cb600d5a3eb095c2003bb88bd031403e47c9 Reviewed-by: Simon Hausmann --- tools/qmljs/main.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tools') 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; -- cgit v1.2.3