diff options
author | Katja Marttila <katja.marttila@qt.io> | 2023-03-15 14:50:47 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2023-03-21 12:23:13 +0000 |
commit | b67df147aedb967a9835766437cd63030013f27b (patch) | |
tree | 48f31106c32da5bc04c3b9ada606f368f1ee9639 /src/libs/installer/scriptengine.cpp | |
parent | e374743d93a3b4d9d7bd593ed010653c6ef72645 (diff) |
Add more detailed error messages
Once installer is started, metadata is downloaded to cache and that
cache is used later to speed the installation process. Cache should not
get invalid but sometimes that can happen. Informing user where the
cache exists and that clearing it might help when the error occurs.
Task-number: QTIFW-2998
Change-Id: Ia2c2a1209fa84070f9ad337c63a429a1afd721a7
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs/installer/scriptengine.cpp')
-rw-r--r-- | src/libs/installer/scriptengine.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index bcd475d54..baf348868 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -34,6 +34,7 @@ #include "loggingutils.h" #include "packagemanagergui.h" #include "component.h" +#include "settings.h" #include <QMetaEnum> #include <QQmlEngine> @@ -377,9 +378,9 @@ QString QFileDialogProxy::getExistingFileOrDirectory(const QString &caption, /*! Constructs a script engine with \a core as parent. */ -ScriptEngine::ScriptEngine(PackageManagerCore *core) : - QObject(core), - m_guiProxy(new GuiProxy(this, this)) +ScriptEngine::ScriptEngine(PackageManagerCore *core) : QObject(core) + , m_guiProxy(new GuiProxy(this, this)) + , m_core(core) { m_engine.installExtensions(QJSEngine::TranslationExtension); QJSValue global = m_engine.globalObject(); @@ -574,14 +575,17 @@ QJSValue ScriptEngine::callScriptMethod(const QJSValue &scriptContext, const QSt if (!method.isCallable()) return QJSValue(QJSValue::UndefinedValue); if (method.isError()) { - throw Error(method.toString().isEmpty() ? QString::fromLatin1("Unknown error.") - : method.toString()); + QString errorString = method.toString().isEmpty() ? QString::fromLatin1("Unknown error.") + : method.toString(); + + throw Error(QString::fromLatin1("%1 \n%2 \"%3\"").arg(errorString, tr(scClearCacheHint), m_core->settings().localCachePath())); } const QJSValue result = method.call(arguments); if (result.isError()) { - throw Error(result.toString().isEmpty() ? QString::fromLatin1("Unknown error.") - : result.toString()); + QString errorString = result.toString().isEmpty() ? QString::fromLatin1("Unknown error.") + : result.toString(); + throw Error(QString::fromLatin1("%1 \n%2 \"%3\"").arg(errorString, tr(scClearCacheHint), m_core->settings().localCachePath())); } stack.removeLast(); |