diff options
author | Michal Klocek <michal.klocek@digia.com> | 2013-01-31 14:20:37 +0100 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@digia.com> | 2013-01-31 18:21:01 +0100 |
commit | a68325be2c9bddedf7415a865e911f0dfdef766c (patch) | |
tree | 089e7da7ea8b6285896a684dc3300dfac226e00b /src | |
parent | a1f3bb5f225bb53e131209e6a0c0854a86be4820 (diff) |
Adds custom error message for executeoperation
Change-Id: Ib049bc9e91566eb8f53ea946e0fc62d3580c2957
Reviewed-by: Niels Weber <niels.weber@digia.com>
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/elevatedexecuteoperation.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/libs/installer/elevatedexecuteoperation.cpp b/src/libs/installer/elevatedexecuteoperation.cpp index 2d5bab2e4..e9452ddcb 100644 --- a/src/libs/installer/elevatedexecuteoperation.cpp +++ b/src/libs/installer/elevatedexecuteoperation.cpp @@ -115,6 +115,15 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments) args.removeAll(workingDirectoryArgument); } + QString customErrorMessage; + QStringList filteredCustomErrorMessage = args.filter(QLatin1String("errormessage="), + Qt::CaseInsensitive); + if (!filteredCustomErrorMessage.isEmpty()) { + QString customErrorMessageArgument = filteredCustomErrorMessage.at(0); + customErrorMessage = customErrorMessageArgument; + customErrorMessage.replace(QLatin1String("errormessage="), QString(), Qt::CaseInsensitive); + args.removeAll(customErrorMessageArgument); + } if (args.last().endsWith(QLatin1String("showStandardError"))) { showStandardError = true; @@ -214,8 +223,12 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments) if (!allowedExitCodes.contains(process->exitCode())) { q->setError(UserDefinedError); - q->setErrorString(tr("Execution failed(Unexpected exit code: %1): \"%2\"") - .arg(QString::number(process->exitCode()), callstr)); + if (customErrorMessage.isEmpty()) { + q->setErrorString(tr("Execution failed(Unexpected exit code: %1): \"%2\"") + .arg(QString::number(process->exitCode()), callstr)); + } else { + q->setErrorString(customErrorMessage); + } returnValue = false; } |