From 86d2d5d3a2568982468d19bfae3b19bfb6b42457 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 15 Jul 2009 17:09:51 +0200 Subject: Fix the return value of a function call that throws an error. --- src/script/api/qscriptvalue.cpp | 4 +++- tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index c3c7c18..79c769a 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1987,8 +1987,10 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject, JSC::CallData callData; JSC::CallType callType = callee.getCallData(callData); JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, jscArgs); - if (exec->hadException()) + if (exec->hadException()) { eng_p->uncaughtException = exec->exception(); + result = exec->exception(); + } return eng_p->scriptValueFromJSCValue(result); } diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 2eff71a..b0df6fd 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2354,10 +2354,8 @@ void tst_QScriptValue::call() { QScriptValue result = fun.call(); - QEXPECT_FAIL("", "Returns null if a function throws an error", Continue); QCOMPARE(result.isError(), true); QCOMPARE(eng.hasUncaughtException(), true); - QEXPECT_FAIL("", "returns null if a function throws an error", Continue); QVERIFY(result.strictlyEquals(eng.uncaughtException())); } } -- cgit v0.12