summaryrefslogtreecommitdiffstats
path: root/installerbuilder
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@nokia.com>2011-08-25 13:20:54 +0200
committerTim Jenssen <tim.jenssen@nokia.com>2011-08-25 15:04:51 +0200
commit8f84b31778f15623a747d5b1be0ec6ef952081df (patch)
tree261ae5a0311303d0fe338ecc730e416302adbe1e /installerbuilder
parentc1e2bf3486993f79942225dd42b4ba88fc59f731 (diff)
Add a context paramter to be able to pass some other info.
Change-Id: Ibdf7d56b421c932d3ebe9836ee4562bf5cd6762f Reviewed-on: http://codereview.qt.nokia.com/3589 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
Diffstat (limited to 'installerbuilder')
-rw-r--r--installerbuilder/libinstaller/component.cpp8
-rw-r--r--installerbuilder/libinstaller/packagemanagercore.cpp20
-rw-r--r--installerbuilder/libinstaller/qinstallerglobal.h2
3 files changed, 13 insertions, 17 deletions
diff --git a/installerbuilder/libinstaller/component.cpp b/installerbuilder/libinstaller/component.cpp
index 0ab9987f7..00581b548 100644
--- a/installerbuilder/libinstaller/component.cpp
+++ b/installerbuilder/libinstaller/component.cpp
@@ -356,12 +356,12 @@ void Component::loadComponentScript(const QString &fileName)
{
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
- throw Error(tr("Could not open the requested script file at %1: %2").arg(fileName, file.errorString()));
+ throw Error(tr("Could not open the requested script file at %1: %2.").arg(fileName, file.errorString()));
}
d->m_scriptEngine.evaluate(QLatin1String(file.readAll()), fileName);
if (d->m_scriptEngine.hasUncaughtException()) {
- throw Error(tr("Exception while loading the component script %1")
+ throw Error(tr("Exception while loading the component script: %1")
.arg(uncaughtExceptionString(&(d->m_scriptEngine)/*, QFileInfo(file).absoluteFilePath()*/)));
}
@@ -381,8 +381,8 @@ void Component::loadComponentScript(const QString &fileName)
//evaluate("Component") and construct can have an exception
if (d->m_scriptEngine.hasUncaughtException()) {
- throw Error(tr("Exception while loading the component script %1")
- .arg(uncaughtExceptionString(&(d->m_scriptEngine)/*, QFileInfo(file).absoluteFilePath()*/)));
+ throw Error(tr("Exception while loading the component script: %1")
+ .arg(uncaughtExceptionString(&(d->m_scriptEngine), QFileInfo(file).absoluteFilePath())));
}
emit loaded();
diff --git a/installerbuilder/libinstaller/packagemanagercore.cpp b/installerbuilder/libinstaller/packagemanagercore.cpp
index fb07deb47..851adc439 100644
--- a/installerbuilder/libinstaller/packagemanagercore.cpp
+++ b/installerbuilder/libinstaller/packagemanagercore.cpp
@@ -179,18 +179,14 @@ QScriptValue QInstaller::qDesktopServicesStorageLocation(QScriptContext* context
return QDesktopServices::storageLocation(location);
}
-QString QInstaller::uncaughtExceptionString(QScriptEngine *scriptEngine/*, const QString &context*/)
-{
- //QString errorString(QLatin1String("%1 %2\n%3"));
- QString errorString(QLatin1String("\t\t%1\n%2"));
- //if (!context.isEmpty())
- // errorString.prepend(context + QLatin1String(": "));
-
- //usually the line number is in the backtrace
- errorString = errorString.arg(/*QString::number(scriptEngine->uncaughtExceptionLineNumber()),*/
- scriptEngine->uncaughtException().toString(), scriptEngine->uncaughtExceptionBacktrace()
- .join(QLatin1String("\n")));
- return errorString;
+QString QInstaller::uncaughtExceptionString(QScriptEngine *scriptEngine, const QString &context)
+{
+ QString error(QLatin1String("\n\n%1\n\nBacktrace:\n\t%2"));
+ if (!context.isEmpty())
+ error.prepend(context);
+
+ return error.arg(scriptEngine->uncaughtException().toString(), scriptEngine->uncaughtExceptionBacktrace()
+ .join(QLatin1String("\n\t")));
}
diff --git a/installerbuilder/libinstaller/qinstallerglobal.h b/installerbuilder/libinstaller/qinstallerglobal.h
index e7a088779..11d05ef8a 100644
--- a/installerbuilder/libinstaller/qinstallerglobal.h
+++ b/installerbuilder/libinstaller/qinstallerglobal.h
@@ -67,7 +67,7 @@ typedef QList<QInstaller::Package*> PackagesList;
typedef KDUpdater::PackageInfo LocalPackage;
typedef QHash<QString, LocalPackage> LocalPackagesHash;
-QString uncaughtExceptionString(QScriptEngine *scriptEngine);
+QString uncaughtExceptionString(QScriptEngine *scriptEngine, const QString &context = QString());
QScriptValue qInstallerComponentByName(QScriptContext *context, QScriptEngine *engine);
QScriptValue qDesktopServicesOpenUrl(QScriptContext *context, QScriptEngine *engine);