Declare `RuntimeException` as the return type to make it easier for callers to throw unconditionally.
@@ -151,9 +151,9 @@ public abstract class BugReport {
*
* <p>Has no effect if another crash has already been handled by {@link BugReport}.
*/
- public static void handleCrashWithoutSendingBugReport(
+ public static RuntimeException handleCrashWithoutSendingBugReport(
Throwable throwable, ExitCode exitCode, String... args) {
- handleCrash(
+ throw handleCrash(
throwable,
/*sendBugReport=*/ false,
DetailedExitCode.of(exitCode, CrashFailureDetails.forThrowable(throwable)),
@@ -166,8 +166,9 @@ public abstract class BugReport {
*
* <p>Has no effect if another crash has already been handled by {@link BugReport}.
*/
- public static void handleCrash(Throwable throwable, ExitCode exitCode, String... args) {
- handleCrash(
+ public static RuntimeException handleCrash(
+ Throwable throwable, ExitCode exitCode, String... args) {
+ throw handleCrash(
throwable,
/*sendBugReport=*/ true,
DetailedExitCode.of(exitCode, CrashFailureDetails.forThrowable(throwable)),
@@ -314,11 +315,11 @@ public abstract class BugReport {
logger.atSevere().withCause(exception).log("Exception");
// The preamble is used in the crash watcher, so don't change it
// unless you know what you're doing.
- String preamble = getProductName()
+ String preamble =
+ getProductName()
+ (exception instanceof OutOfMemoryError ? " OOMError: " : " crashed with args: ");
- LoggingUtil.logToRemote(Level.SEVERE, preamble + Joiner.on(' ').join(args), exception,
- values);
+ LoggingUtil.logToRemote(Level.SEVERE, preamble + Joiner.on(' ').join(args), exception, values);
}
private static class DefaultBugReporter implements BugReporter {
