Skip to content
Snippets Groups Projects
Commit 04f77f8d authored by Joris van Zwieten's avatar Joris van Zwieten
Browse files

Task #3458: Added checks on command status returned by Command::accept().

parent 7f22325e
No related branches found
No related tags found
No related merge requests found
...@@ -235,7 +235,13 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList &args) ...@@ -235,7 +235,13 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList &args)
// Fake intialization. // Fake intialization.
InitializeCommand initCmd(strategy); InitializeCommand initCmd(strategy);
initCmd.accept(handler); CommandResult initResult = initCmd.accept(handler);
if(!initResult)
{
LOG_ERROR_STR("Error executing " << initCmd.type() << " command: "
<< initResult.message());
return 1;
}
// Fake session control. // Fake session control.
StrategyIterator it; StrategyIterator it;
...@@ -243,9 +249,19 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList &args) ...@@ -243,9 +249,19 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList &args)
{ {
if(!it.atEnd()) if(!it.atEnd())
{ {
// Execute the current command.
LOG_DEBUG_STR("Executing a " << (*it)->type() << " command:" << endl LOG_DEBUG_STR("Executing a " << (*it)->type() << " command:" << endl
<< **it); << **it);
(*it)->accept(handler); CommandResult result = (*it)->accept(handler);
if(!result)
{
LOG_ERROR_STR("Error executing " << (*it)->type() << " command: "
<< result.message());
return 1;
}
// Move to the next command in the strategy.
++it; ++it;
} }
else else
...@@ -255,7 +271,17 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList &args) ...@@ -255,7 +271,17 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList &args)
{ {
// Fake finalization. // Fake finalization.
FinalizeCommand finCmd; FinalizeCommand finCmd;
finCmd.accept(handler);
LOG_DEBUG_STR("Executing a " << finCmd.type() << " command:" << endl
<< finCmd);
CommandResult result = finCmd.accept(handler);
if(!result)
{
LOG_ERROR_STR("Error executing " << finCmd.type() << " command: "
<< result.message());
return 1;
}
} }
else else
{ {
...@@ -270,9 +296,17 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList &args) ...@@ -270,9 +296,17 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList &args)
// Fake next chunk. // Fake next chunk.
NextChunkCommand nextCmd(msFreqRange.first, msFreqRange.second, start, NextChunkCommand nextCmd(msFreqRange.first, msFreqRange.second, start,
end); end);
LOG_DEBUG_STR("Executing a " << nextCmd.type() << " command:" << endl LOG_DEBUG_STR("Executing a " << nextCmd.type() << " command:" << endl
<< nextCmd); << nextCmd);
nextCmd.accept(handler); CommandResult result = nextCmd.accept(handler);
if(!result)
{
LOG_ERROR_STR("Error executing " << nextCmd.type() << " command: "
<< result.message());
return 1;
}
// Re-initialize strategy iterator. // Re-initialize strategy iterator.
it = StrategyIterator(strategy); it = StrategyIterator(strategy);
...@@ -368,7 +402,7 @@ int runDistributed(const ParameterSet &options, ...@@ -368,7 +402,7 @@ int runDistributed(const ParameterSet &options,
session.postResult(command.first, result); session.postResult(command.first, result);
// If an error occurred, log a descriptive message and exit. // If an error occurred, log a descriptive message and exit.
if(result.is(CommandResult::ERROR)) if(!result)
{ {
LOG_ERROR_STR("Error executing " << command.second->type() LOG_ERROR_STR("Error executing " << command.second->type()
<< " command: " << result.message()); << " command: " << result.message());
......
...@@ -188,7 +188,7 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList&) ...@@ -188,7 +188,7 @@ int run(const ParameterSet &options, const OptionParser::ArgumentList&)
session.postResult(command.first, result); session.postResult(command.first, result);
// If an error occurred, log a descriptive message and exit. // If an error occurred, log a descriptive message and exit.
if(result.is(CommandResult::ERROR)) if(!result)
{ {
LOG_ERROR_STR("Error executing " << command.second->type() LOG_ERROR_STR("Error executing " << command.second->type()
<< " command: " << result.message()); << " command: " << result.message());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment