diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-10-21 09:50:27 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-29 10:38:55 +0100 |
commit | e0284ab41f7a1889f28e719212df66e942959f4c (patch) | |
tree | dfbd27e96968c07d49372c6ed06f0b51f2c6c8b8 /src/qml/jsruntime/qv4include.cpp | |
parent | 59cc901d3d15079b3666e5902b4c8b1a83ff1fd2 (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 'src/qml/jsruntime/qv4include.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4include.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 47d2832fa3..355817ef3e 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -157,14 +157,15 @@ void QV4Include::finished() QV4::ExecutionContext *ctx = v4->current; QV4::ScopedString status(scope, v4->newString("status")); - try { - script.parse(); + script.parse(); + if (!scope.engine->hasException) script.run(); - resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Ok))); - } catch (...) { + if (scope.engine->hasException) { QV4::ScopedValue ex(scope, ctx->catchException()); resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Exception))); resultObj->put(QV4::ScopedString(scope, v4->newString("exception")), ex); + } else { + resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Ok))); } } else { resultObj->put(QV4::ScopedString(scope, v4->newString("status")), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError))); @@ -222,14 +223,15 @@ QV4::ReturnedValue QV4Include::method_include(QV4::SimpleCallContext *ctx) QV4::Script script(v4, qmlcontextobject, code, url.toString()); QV4::ExecutionContext *ctx = v4->current; - try { - script.parse(); + script.parse(); + if (!v4->hasException) script.run(); - result = resultValue(v4, Ok); - } catch (...) { + if (v4->hasException) { QV4::ScopedValue ex(scope, ctx->catchException()); result = resultValue(v4, Exception); result->asObject()->put(QV4::ScopedString(scope, v4->newString("exception")), ex); + } else { + result = resultValue(v4, Ok); } } else { result = resultValue(v4, NetworkError); |