mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
fail fast on command errors in session
This commit is contained in:
parent
c1f182f306
commit
c579ca38cd
@ -84,6 +84,7 @@ public class NBSession extends NBHeartbeatComponent implements Function<List<Cmd
|
||||
// TODO: inject container closing commands after the last command referencing each container
|
||||
List<NBCommandAssembly.CommandInvocation> invocationCalls = NBCommandAssembly.assemble(cmds, this::getContext);
|
||||
ResultCollector collector = new ResultCollector();
|
||||
// TODO: When a command is not successful, automatically break out of the command loop
|
||||
try (ResultContext results = new ResultContext(collector).ok()) {
|
||||
for (NBCommandAssembly.CommandInvocation invocation : invocationCalls) {
|
||||
String targetContext = invocation.containerName();
|
||||
@ -93,11 +94,14 @@ public class NBSession extends NBHeartbeatComponent implements Function<List<Cmd
|
||||
NBBufferedContainer container = getContext(targetContext);
|
||||
NBCommandResult cmdResult = container.apply(command, invocation.params());
|
||||
results.apply(cmdResult);
|
||||
if (cmdResult.hasException()) {
|
||||
throw cmdResult.getException();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String msg = "While running " + explanation + "', an error occurred: " + e.toString();
|
||||
results.error(e);
|
||||
onError(e);
|
||||
logger.error(msg);
|
||||
results.error(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user