mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-27 09:11:08 -06:00
minor cleanup on error handling output
This commit is contained in:
parent
ac22b3b395
commit
be74656211
@ -18,6 +18,7 @@ import io.nosqlbench.engine.core.script.MetricsMapper;
|
|||||||
import io.nosqlbench.engine.core.script.Scenario;
|
import io.nosqlbench.engine.core.script.Scenario;
|
||||||
import io.nosqlbench.engine.core.script.ScenariosExecutor;
|
import io.nosqlbench.engine.core.script.ScenariosExecutor;
|
||||||
import io.nosqlbench.nb.api.markdown.exporter.MarkdownExporter;
|
import io.nosqlbench.nb.api.markdown.exporter.MarkdownExporter;
|
||||||
|
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||||
import io.nosqlbench.virtdata.userlibs.apps.VirtDataMainApp;
|
import io.nosqlbench.virtdata.userlibs.apps.VirtDataMainApp;
|
||||||
import io.nosqlbench.docsys.core.DocServerApp;
|
import io.nosqlbench.docsys.core.DocServerApp;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -51,14 +52,12 @@ public class NBCLI {
|
|||||||
NBCLI cli = new NBCLI("eb");
|
NBCLI cli = new NBCLI("eb");
|
||||||
cli.run(args);
|
cli.run(args);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof BasicError) {
|
String error = ScenarioErrorHandler.handle(e,true);
|
||||||
// System.out.println("ERROR: " + e.getMessage());
|
if (error!=null) {
|
||||||
// System.out.flush();
|
System.out.println(error);
|
||||||
logger.error("ERROR: " + e.getMessage());
|
|
||||||
System.exit(2);
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
System.out.flush();
|
||||||
|
System.exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,12 +284,12 @@ public class NBCLI {
|
|||||||
|
|
||||||
// Execute Scenario!
|
// Execute Scenario!
|
||||||
|
|
||||||
Level clevel = options.wantsConsoleLogLevel();
|
Level consoleLogLevel = options.wantsConsoleLogLevel();
|
||||||
Level llevel = Level.toLevel(options.getLogsLevel());
|
Level scenarioLogLevel = Level.toLevel(options.getLogsLevel());
|
||||||
if (llevel.toInt() > clevel.toInt()) {
|
if (scenarioLogLevel.toInt() > consoleLogLevel.toInt()) {
|
||||||
logger.info("raising scenario logging level to accommodate console logging level");
|
logger.info("raising scenario logging level to accommodate console logging level");
|
||||||
}
|
}
|
||||||
Level maxLevel = Level.toLevel(Math.min(clevel.toInt(), llevel.toInt()));
|
Level maxLevel = Level.toLevel(Math.min(consoleLogLevel.toInt(), scenarioLogLevel.toInt()));
|
||||||
|
|
||||||
scenario.addScriptText(scriptData);
|
scenario.addScriptText(scriptData);
|
||||||
ScriptParams scriptParams = new ScriptParams();
|
ScriptParams scriptParams = new ScriptParams();
|
||||||
@ -320,10 +319,13 @@ public class NBCLI {
|
|||||||
scenariosResults.reportToLog();
|
scenariosResults.reportToLog();
|
||||||
ShutdownManager.shutdown();
|
ShutdownManager.shutdown();
|
||||||
|
|
||||||
|
logger.info(scenariosResults.getExecutionSummary());
|
||||||
|
|
||||||
if (scenariosResults.hasError()) {
|
if (scenariosResults.hasError()) {
|
||||||
Exception exception = scenariosResults.getOne().getException().get();
|
Exception exception = scenariosResults.getOne().getException().get();
|
||||||
// logger.warn(scenariosResults.getExecutionSummary());
|
// logger.warn(scenariosResults.getExecutionSummary());
|
||||||
ScenarioErrorHandler.handle(exception,options.wantsStackTraces());
|
ScenarioErrorHandler.handle(exception,options.wantsStackTraces());
|
||||||
|
System.out.println(exception.getMessage()); // TODO: make this consistent with ConsoleLogging sequencing
|
||||||
System.exit(2);
|
System.exit(2);
|
||||||
} else {
|
} else {
|
||||||
logger.info(scenariosResults.getExecutionSummary());
|
logger.info(scenariosResults.getExecutionSummary());
|
||||||
|
@ -28,17 +28,19 @@ public class ScenarioErrorHandler {
|
|||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ScenarioErrorHandler.class);
|
private final static Logger logger = LoggerFactory.getLogger(ScenarioErrorHandler.class);
|
||||||
|
|
||||||
public static void handle(Throwable t, boolean wantsStackTraces) {
|
public static String handle(Throwable t, boolean wantsStackTraces) {
|
||||||
if (t instanceof ScriptException) {
|
if (t instanceof ScriptException) {
|
||||||
handleScriptException((ScriptException) t, wantsStackTraces);
|
return handleScriptException((ScriptException) t, wantsStackTraces);
|
||||||
} else if (t instanceof BasicError) {
|
} else if (t instanceof BasicError) {
|
||||||
handleBasicError((BasicError) t, wantsStackTraces);
|
return handleBasicError((BasicError) t, wantsStackTraces);
|
||||||
} else if (t instanceof Exception){
|
} else if (t instanceof Exception){
|
||||||
handleInternalError((Exception) t, wantsStackTraces);
|
return handleInternalError((Exception) t, wantsStackTraces);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Error in exception handler", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleInternalError(Exception e, boolean wantsStackTraces) {
|
private static String handleInternalError(Exception e, boolean wantsStackTraces) {
|
||||||
String prefix = "internal error: ";
|
String prefix = "internal error: ";
|
||||||
if (e.getCause()!=null && !e.getCause().getClass().getCanonicalName().contains("io.nosqlbench")) {
|
if (e.getCause()!=null && !e.getCause().getClass().getCanonicalName().contains("io.nosqlbench")) {
|
||||||
prefix = "Error from driver or included library: ";
|
prefix = "Error from driver or included library: ";
|
||||||
@ -50,9 +52,10 @@ public class ScenarioErrorHandler {
|
|||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
logger.error("for the full stack trace, run with --show-stacktraces");
|
logger.error("for the full stack trace, run with --show-stacktraces");
|
||||||
}
|
}
|
||||||
|
return e.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleScriptException(ScriptException e, boolean wantsStackTraces) {
|
private static String handleScriptException(ScriptException e, boolean wantsStackTraces) {
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
if (cause instanceof PolyglotException) {
|
if (cause instanceof PolyglotException) {
|
||||||
Throwable hostException = ((PolyglotException) cause).asHostException();
|
Throwable hostException = ((PolyglotException) cause).asHostException();
|
||||||
@ -69,15 +72,17 @@ public class ScenarioErrorHandler {
|
|||||||
logger.error("for the full stack trace, run with --show-stacktraces");
|
logger.error("for the full stack trace, run with --show-stacktraces");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return e.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleBasicError(BasicError e, boolean wantsStackTraces) {
|
private static String handleBasicError(BasicError e, boolean wantsStackTraces) {
|
||||||
if (wantsStackTraces) {
|
if (wantsStackTraces) {
|
||||||
logger.error(e.getMessage(),e);
|
logger.error(e.getMessage(),e);
|
||||||
} else {
|
} else {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
logger.error("for the full stack trace, run with --show-stacktraces");
|
logger.error("for the full stack trace, run with --show-stacktraces");
|
||||||
}
|
}
|
||||||
|
return e.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,16 @@ public class ScenarioResult {
|
|||||||
return Optional.ofNullable(exception);
|
return Optional.ofNullable(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rethrowIfError() {
|
||||||
|
if (exception!=null) {
|
||||||
|
if (exception instanceof RuntimeException) {
|
||||||
|
throw ((RuntimeException) exception);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getIOLog() {
|
public String getIOLog() {
|
||||||
return this.iolog;
|
return this.iolog;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user