#include <iostream>
+#include <client/snapper/cmd.h>
#include <snapper/AppUtil.h>
#include "../utils/text.h"
if (WIFEXITED(status)) {
int const exit_status = WEXITSTATUS(status);
if (exit_status != 0) {
- // TODO(epg): Can we have snapper itself exit with this status?
- SN_THROW(Exception(sformat("%s exited %d", command.c_str(), exit_status)));
+ SN_THROW(CommandException(exit_status));
}
} else {
SN_THROW(Exception(sformat("%s killed with %d", command.c_str(), WTERMSIG(status))));
command_debug(GlobalOptions& global_options, GetOpts& get_opts, ProxySnappers* snappers,
ProxySnapper* snapper, Plugins::Report& report);
+ struct CommandException : public Exception
+ {
+ explicit CommandException(int exit_status)
+ : Exception(),
+ exit_status(exit_status)
+ {}
+
+ const int exit_status;
+ };
+
}
cerr << e.what() << endl;
exit(EXIT_FAILURE);
}
+ catch (const CommandException& e)
+ {
+ SN_CAUGHT(e);
+ exit(e.exit_status);
+ }
catch (const Exception& e)
{
SN_CAUGHT(e);
<listitem>
<para>Create a pre and post snapshot and run command in between. If snapper is
unable to execute the command at all, it does not take the post snapshot. If the
- command exits with a non-zero exit code, snapper takes the post snapshot and exits 1
- to indicate the failure.</para>
+ command exits with a non-zero exit code, snapper takes the post snapshot and exits
+ with that same exit code.</para>
</listitem>
</varlistentry>
<varlistentry>