From 22ef109ccdc64e0f9afb82b1b7b3d4c39e31a5ab Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Mon, 2 Jul 2018 11:47:58 +0200 Subject: [PATCH] Improve error message Change-Id: I29b9a35c080c50469ac1a3ff5f83a31349e801ad Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4runtime.cpp | 4 +++- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 23170ace92..5f8b7d31ca 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -487,8 +487,10 @@ Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Val Q_ASSERT(!value.isObject()); switch (value.type()) { case Value::Undefined_Type: + engine->throwTypeError(QLatin1String("Value is undefined and could not be converted to an object")); + return nullptr; case Value::Null_Type: - engine->throwTypeError(); + engine->throwTypeError(QLatin1String("Value is null and could not be converted to an object")); return nullptr; case Value::Boolean_Type: return engine->newBooleanObject(value.booleanValue()); diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index acdee3a808..2e8f61ef10 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -8103,7 +8103,7 @@ void tst_qqmlecmascript::setPropertyOnInvalid() QQmlEngine engine; { QQmlComponent component(&engine, testFileUrl("setPropertyOnNull.qml")); - QString warning = component.url().toString() + ":4: TypeError: Type error"; + QString warning = component.url().toString() + ":4: TypeError: Value is null and could not be converted to an object"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QObject *object = component.create(); QVERIFY(object); @@ -8112,7 +8112,7 @@ void tst_qqmlecmascript::setPropertyOnInvalid() { QQmlComponent component(&engine, testFileUrl("setPropertyOnUndefined.qml")); - QString warning = component.url().toString() + ":4: TypeError: Type error"; + QString warning = component.url().toString() + ":4: TypeError: Value is undefined and could not be converted to an object"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QObject *object = component.create(); QVERIFY(object);