Display the full stack trace if requested
If a command line tool like init or daemon dies the user might want to re-run the tool using --show-stack-trace to collect the complete trace to include in a bug report, or use to debug the application. Change-Id: I166699004642970c1424b0be6ca9f22f766e5f80 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -31,6 +31,9 @@ public abstract class AbstractProgram {
|
||||
private final Object sleepLock = new Object();
|
||||
private boolean running = true;
|
||||
|
||||
@Option(name = "--show-stack-trace", usage = "display stack trace on failure")
|
||||
private boolean showStackTrace;
|
||||
|
||||
@Option(name = "--help", usage = "display this help text", aliases = {"-h"})
|
||||
private boolean help;
|
||||
|
||||
@@ -72,13 +75,17 @@ public abstract class AbstractProgram {
|
||||
ProxyUtil.configureHttpProxy();
|
||||
return run();
|
||||
} catch (Die err) {
|
||||
final Throwable cause = err.getCause();
|
||||
final String diemsg = err.getMessage();
|
||||
if (cause != null && !cause.getMessage().equals(diemsg)) {
|
||||
System.err.println("fatal: "
|
||||
+ cause.getMessage().replaceAll("\n", "\nfatal: "));
|
||||
if (showStackTrace) {
|
||||
err.printStackTrace();
|
||||
} else {
|
||||
final Throwable cause = err.getCause();
|
||||
final String diemsg = err.getMessage();
|
||||
if (cause != null && !cause.getMessage().equals(diemsg)) {
|
||||
System.err.println("fatal: "
|
||||
+ cause.getMessage().replaceAll("\n", "\nfatal: "));
|
||||
}
|
||||
System.err.println("fatal: " + diemsg.replaceAll("\n", "\nfatal: "));
|
||||
}
|
||||
System.err.println("fatal: " + diemsg.replaceAll("\n", "\nfatal: "));
|
||||
return 128;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<booleanAttribute key="org.eclipse.jdt.debug.ui.CONSIDER_INHERITED_MAIN" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Main"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="daemon --console-log"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="daemon --console-log --show-stack-trace"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit-war"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M"/>
|
||||
|
||||
Reference in New Issue
Block a user