forked from qt-creator/qt-creator
Process: Introduce exitMessage() helper
This is going to be used for tweaked process result. Change-Id: I1e4117dcd6145e4748a55c285b2546974a6e7d00 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -1651,26 +1651,31 @@ QString Process::readAllStandardError()
|
|||||||
return QString::fromUtf8(readAllRawStandardError());
|
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();
|
const QString cmd = command.toUserOutput();
|
||||||
switch (result()) {
|
switch (result) {
|
||||||
case ProcessResult::FinishedWithSuccess:
|
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:
|
case ProcessResult::FinishedWithError:
|
||||||
return Tr::tr("The command \"%1\" terminated with exit code %2.")
|
return Tr::tr("The command \"%1\" terminated with exit code %2.").arg(cmd).arg(exitCode);
|
||||||
.arg(fullCmd).arg(exitCode());
|
|
||||||
case ProcessResult::TerminatedAbnormally:
|
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:
|
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:
|
case ProcessResult::Hang:
|
||||||
return Tr::tr("The command \"%1\" did not respond within the timeout limit (%2 s).")
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Process::exitMessage() const
|
||||||
|
{
|
||||||
|
return exitMessage(commandLine(), result(), exitCode(), timeoutS());
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray Process::allRawOutput() const
|
QByteArray Process::allRawOutput() const
|
||||||
{
|
{
|
||||||
QTC_CHECK(d->m_stdOut.keepRawData);
|
QTC_CHECK(d->m_stdOut.keepRawData);
|
||||||
|
@@ -182,6 +182,8 @@ public:
|
|||||||
const QStringList stdOutLines() const; // split, CR removed
|
const QStringList stdOutLines() const; // split, CR removed
|
||||||
const QStringList stdErrLines() 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 exitMessage() const;
|
||||||
|
|
||||||
QString toStandaloneCommandLine() const;
|
QString toStandaloneCommandLine() const;
|
||||||
|
Reference in New Issue
Block a user