diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-01-21 18:30:09 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-01-22 10:17:13 +0100 |
commit | c1bcaca07fc89b3a7e21dc6ca2958b7938eb3a40 (patch) | |
tree | bc4c4ba8234baf50c14c6ac030a24456dfa7ad37 /tests/auto | |
parent | dea48b7e47e54236453cf83c8ef5670142fe01a2 (diff) |
QJSEngine: Add a function to throw a pre-generated error object
It makes little sense that you can construct an error object but not
throw it. The test was definitely meant to actually throw the error
object, not return it.
[ChangeLog][QtQml] QJSEngine has gained an additional overload to the
throwError() method, with the effect that calling throwError() with a
character literal as argument is now ambiguous. You should explicitly
construct a QString instead.
Change-Id: I90c6c9edf10509daa142a86581d6a3f7ff45af2c
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qjsengine/tst_qjsengine.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index a5316dce21..85d61a3537 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -4826,7 +4826,7 @@ void tst_QJSEngine::catchError() QJSValue tst_QJSEngine::throwingCppMethod1() { - qjsEngine(this)->throwError("blub"); + qjsEngine(this)->throwError(QStringLiteral("blub")); return QJSValue(47); } @@ -4837,7 +4837,9 @@ void tst_QJSEngine::throwingCppMethod2() QJSValue tst_QJSEngine::throwingCppMethod3() { - return qjsEngine(this)->newErrorObject(QJSValue::EvalError, "Something is wrong"); + QJSEngine *engine = qjsEngine(this); + engine->throwError(engine->newErrorObject(QJSValue::EvalError, "Something is wrong")); + return QJSValue(31); } void tst_QJSEngine::mathMinMax() |