restore main error output

This commit is contained in:
Jonathan Shook 2020-07-17 11:19:21 -05:00
parent a05c95d26f
commit f4d94e282b
3 changed files with 7 additions and 8 deletions

View File

@ -321,8 +321,9 @@ public class NBCLI {
ShutdownManager.shutdown();
if (scenariosResults.hasError()) {
logger.warn(scenariosResults.getExecutionSummary());
logger.error("error running scenario:",scenariosResults.getOne().getException().get());
Exception exception = scenariosResults.getOne().getException().get();
// logger.warn(scenariosResults.getExecutionSummary());
ScenarioErrorHandler.handle(exception,options.wantsStackTraces());
System.exit(2);
} else {
logger.info(scenariosResults.getExecutionSummary());

View File

@ -28,9 +28,9 @@ public class ScenarioErrorHandler {
private final static Logger logger = LoggerFactory.getLogger(ScenarioErrorHandler.class);
public static void handle(String script, Throwable t, boolean wantsStackTraces) {
public static void handle(Throwable t, boolean wantsStackTraces) {
if (t instanceof ScriptException) {
handleScriptException(script, (ScriptException) t, wantsStackTraces);
handleScriptException((ScriptException) t, wantsStackTraces);
} else if (t instanceof BasicError) {
handleBasicError((BasicError) t, wantsStackTraces);
} else if (t instanceof Exception){
@ -52,14 +52,14 @@ public class ScenarioErrorHandler {
}
}
private static void handleScriptException(String script, ScriptException e, boolean wantsStackTraces) {
private static void handleScriptException(ScriptException e, boolean wantsStackTraces) {
Throwable cause = e.getCause();
if (cause instanceof PolyglotException) {
Throwable hostException = ((PolyglotException) cause).asHostException();
if (hostException instanceof BasicError) {
handleBasicError((BasicError)hostException, wantsStackTraces);
} else {
handle(script,hostException, wantsStackTraces);
handle(hostException, wantsStackTraces);
}
} else {
if (wantsStackTraces) {

View File

@ -217,10 +217,8 @@ public class Scenario implements Callable<ScenarioResult> {
System.err.flush();
System.out.flush();
} catch (Exception e) {
ScenarioErrorHandler.handle(script,e,wantsStackTraces);
throw new RuntimeException(e);
} finally {
scenarioController.forceStopScenario(5000);
System.out.flush();
System.err.flush();
}