Add --stacktrace option

This commit is contained in:
Paul Schaub 2022-11-06 14:41:52 +01:00
parent c32ef9830b
commit fd4c22cde6
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 10 additions and 1 deletions

View file

@ -19,8 +19,13 @@ public class SOPExecutionExceptionHandler implements CommandLine.IExecutionExcep
// CHECKSTYLE:OFF // CHECKSTYLE:OFF
if (ex.getMessage() != null) { if (ex.getMessage() != null) {
commandLine.getErr().println(colorScheme.errorText(ex.getMessage())); commandLine.getErr().println(colorScheme.errorText(ex.getMessage()));
} else {
commandLine.getErr().println(ex.getClass().getName());
} }
if (SopCLI.stacktrace) {
ex.printStackTrace(commandLine.getErr()); ex.printStackTrace(commandLine.getErr());
}
// CHECKSTYLE:ON // CHECKSTYLE:ON
return exitCode; return exitCode;

View file

@ -52,6 +52,10 @@ public class SopCLI {
public static String EXECUTABLE_NAME = "sop"; public static String EXECUTABLE_NAME = "sop";
@CommandLine.Option(names = {"--stacktrace"}, description = "Print Stacktrace",
scope = CommandLine.ScopeType.INHERIT)
static boolean stacktrace;
public static void main(String[] args) { public static void main(String[] args) {
int exitCode = execute(args); int exitCode = execute(args);
if (exitCode != 0) { if (exitCode != 0) {