aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8/qv8include.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-05-20 23:51:45 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-21 10:11:43 +0200
commit7fe54ee6d6eb44c630038229eb9a4bb1780eec77 (patch)
tree20e0278387688936a060eaed33273ca7bb5e89c5 /src/qml/qml/v8/qv8include.cpp
parente1a6612d3a4528fee8854c274232fc4966d65237 (diff)
Convert the remaining TryCatch statements to use QV4::Exception
v8::Script::Run doesn't catch the exception anymore. Instead we handle this on the calling side, removing all needs for v8::TryCatch. Change-Id: I946269a6734f50c728c4f153c00cd19db48f1a6a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/v8/qv8include.cpp')
-rw-r--r--src/qml/qml/v8/qv8include.cpp41
1 files changed, 17 insertions, 24 deletions
diff --git a/src/qml/qml/v8/qv8include.cpp b/src/qml/qml/v8/qv8include.cpp
index 5c24a96847..90c1f5928c 100644
--- a/src/qml/qml/v8/qv8include.cpp
+++ b/src/qml/qml/v8/qv8include.cpp
@@ -144,21 +144,18 @@ void QV8Include::finished()
importContext->isPragmaLibraryContext = m_context->isPragmaLibraryContext;
importContext->setParent(m_context, true);
- v8::TryCatch try_catch;
-
v8::Handle<v8::Script> script = m_engine->qmlModeCompile(code, m_url.toString());
- if (!try_catch.HasCaught()) {
- // ### Only used for debugging info
- //m_engine->contextWrapper()->addSubContext(m_qmlglobal.value(), script, importContext);
+ QV4::ExecutionContext *ctx = QV8Engine::getV4(m_engine)->current;
+ // ### Only used for debugging info
+ //m_engine->contextWrapper()->addSubContext(m_qmlglobal.value(), script, importContext);
+ try {
script->Run(m_qmlglobal.value());
- }
-
- if (try_catch.HasCaught()) {
- v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(Exception));
- v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("exception"), try_catch.Exception());
- } else {
v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(Ok));
+ } catch (QV4::Exception &e) {
+ e.accept(ctx);
+ v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(Exception));
+ v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("exception"), e.value());
}
} else {
v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(NetworkError));
@@ -216,24 +213,20 @@ QV4::Value QV8Include::include(const v8::Arguments &args)
importContext->url = url;
importContext->setParent(context, true);
- v8::TryCatch try_catch;
-
v8::Handle<v8::Script> script = engine->qmlModeCompile(code, url.toString());
- if (!try_catch.HasCaught()) {
- v8::Handle<v8::Object> qmlglobal = QV4::Value::fromObject(args.GetIsolate()->GetEngine()->qmlContextObject());
- // ### Only used for debugging info
- // engine->contextWrapper()->addSubContext(qmlglobal, script, importContext);
+ v8::Handle<v8::Object> qmlglobal = QV4::Value::fromObject(args.GetIsolate()->GetEngine()->qmlContextObject());
+ // ### Only used for debugging info
+ // engine->contextWrapper()->addSubContext(qmlglobal, script, importContext);
+ QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current;
+ try {
script->Run(qmlglobal);
- }
-
- if (try_catch.HasCaught()) {
- result = resultValue(Exception);
- result->Set(v8::String::New("exception"), try_catch.Exception());
- } else {
result = resultValue(Ok);
+ } catch (QV4::Exception &e) {
+ e.accept(ctx);
+ result = resultValue(Exception);
+ result->Set(v8::String::New("exception"), e.value());
}
-
} else {
result = resultValue(NetworkError);
}