diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-01-20 03:23:19 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-01-20 03:23:19 +0100 |
commit | 5ecaed21b5412b0e4b9b9ecf5547ca8225c541a9 (patch) | |
tree | eeff2a041b65f7194182cc18d6d449777203bad7 /logic/launch/steps/PostLaunchCommand.cpp | |
parent | 9fd66b3bb103d668378843766d98a9fe7458d62b (diff) | |
download | MultiMC-5ecaed21b5412b0e4b9b9ecf5547ca8225c541a9.tar MultiMC-5ecaed21b5412b0e4b9b9ecf5547ca8225c541a9.tar.gz MultiMC-5ecaed21b5412b0e4b9b9ecf5547ca8225c541a9.tar.lz MultiMC-5ecaed21b5412b0e4b9b9ecf5547ca8225c541a9.tar.xz MultiMC-5ecaed21b5412b0e4b9b9ecf5547ca8225c541a9.zip |
GH-1411 fail if pre-launch and post-exit commands return non-zero values
Diffstat (limited to 'logic/launch/steps/PostLaunchCommand.cpp')
-rw-r--r-- | logic/launch/steps/PostLaunchCommand.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/logic/launch/steps/PostLaunchCommand.cpp b/logic/launch/steps/PostLaunchCommand.cpp index c7342188..29a45f1b 100644 --- a/logic/launch/steps/PostLaunchCommand.cpp +++ b/logic/launch/steps/PostLaunchCommand.cpp @@ -34,20 +34,34 @@ void PostLaunchCommand::executeTask() void PostLaunchCommand::on_state(LoggedProcess::State state) { + auto getError = [&]() + { + return tr("Post-Launch command failed with code %1.\n\n").arg(m_process.exitCode()); + }; switch(state) { case LoggedProcess::Aborted: case LoggedProcess::Crashed: case LoggedProcess::FailedToStart: { - QString error = tr("Post-Launch command failed with code %1.\n\n").arg(m_process.exitCode()); - emit logLine(error, MessageLevel::Error); + auto error = getError(); + emit logLine(error, MessageLevel::Fatal); emitFailed(error); + return; } case LoggedProcess::Finished: { - emit logLine(tr("Post-Launch command ran successfully.\n\n"), MessageLevel::MultiMC); - emitSucceeded(); + if(m_process.exitCode() != 0) + { + auto error = getError(); + emit logLine(error, MessageLevel::Fatal); + emitFailed(error); + } + else + { + emit logLine(tr("Post-Launch command ran successfully.\n\n"), MessageLevel::MultiMC); + emitSucceeded(); + } } default: break; |