diff --git a/src/libs/utils/process.cpp b/src/libs/utils/process.cpp index dede5bb4dc2..15281eba671 100644 --- a/src/libs/utils/process.cpp +++ b/src/libs/utils/process.cpp @@ -1651,26 +1651,31 @@ QString Process::readAllStandardError() return QString::fromUtf8(readAllRawStandardError()); } -QString Process::exitMessage() const +QString Process::exitMessage(const CommandLine &command, ProcessResult result, int exitCode, + int maxHangTimerCount) { - const QString fullCmd = commandLine().toUserOutput(); - switch (result()) { + const QString cmd = command.toUserOutput(); + switch (result) { case ProcessResult::FinishedWithSuccess: - return Tr::tr("The command \"%1\" finished successfully.").arg(fullCmd); + return Tr::tr("The command \"%1\" finished successfully.").arg(cmd); case ProcessResult::FinishedWithError: - return Tr::tr("The command \"%1\" terminated with exit code %2.") - .arg(fullCmd).arg(exitCode()); + return Tr::tr("The command \"%1\" terminated with exit code %2.").arg(cmd).arg(exitCode); case ProcessResult::TerminatedAbnormally: - return Tr::tr("The command \"%1\" terminated abnormally.").arg(fullCmd); + return Tr::tr("The command \"%1\" terminated abnormally.").arg(cmd); case ProcessResult::StartFailed: - return Tr::tr("The command \"%1\" could not be started.").arg(fullCmd); + return Tr::tr("The command \"%1\" could not be started.").arg(cmd); case ProcessResult::Hang: return Tr::tr("The command \"%1\" did not respond within the timeout limit (%2 s).") - .arg(fullCmd).arg(d->m_maxHangTimerCount); + .arg(cmd).arg(maxHangTimerCount); } return {}; } +QString Process::exitMessage() const +{ + return exitMessage(commandLine(), result(), exitCode(), timeoutS()); +} + QByteArray Process::allRawOutput() const { QTC_CHECK(d->m_stdOut.keepRawData); diff --git a/src/libs/utils/process.h b/src/libs/utils/process.h index 3134894b393..6c3c941b5a7 100644 --- a/src/libs/utils/process.h +++ b/src/libs/utils/process.h @@ -182,6 +182,8 @@ public: const QStringList stdOutLines() const; // split, CR removed const QStringList stdErrLines() const; // split, CR removed + static QString exitMessage(const CommandLine &command, ProcessResult result, + int exitCode, int maxHangTimerCount); QString exitMessage() const; QString toStandaloneCommandLine() const;