Improve error message

Change-Id: I29b9a35c080c50469ac1a3ff5f83a31349e801ad
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Rainer Keller 2018-07-02 11:47:58 +02:00 committed by Simon Hausmann
parent 260e165993
commit 22ef109ccd
2 changed files with 5 additions and 3 deletions

View File

@ -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());

View File

@ -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);