Remove the `Crash` factory overload that permits a custom `ExitCode` without `FailureDetail`.
All crashes that want custom handling (anything besides `33 CRASH_OOM` or `37 CRASH_UNKNOWN`) should pass a `DetailedExitCode` so that consumers have both an exit code and failure detail.
PiperOrigin-RevId: 365662120
diff --git a/src/main/java/com/google/devtools/build/lib/bugreport/Crash.java b/src/main/java/com/google/devtools/build/lib/bugreport/Crash.java
index 33ea9cd..463e22f 100644
--- a/src/main/java/com/google/devtools/build/lib/bugreport/Crash.java
+++ b/src/main/java/com/google/devtools/build/lib/bugreport/Crash.java
@@ -18,7 +18,7 @@
import com.google.common.base.MoreObjects;
import com.google.devtools.build.lib.util.CrashFailureDetails;
import com.google.devtools.build.lib.util.DetailedExitCode;
-import com.google.devtools.build.lib.util.ExitCode;
+
/** Encapsulates the {@link Throwable} and {@link DetailedExitCode} for a crash. */
public final class Crash {
@@ -27,19 +27,16 @@
* Creates a crash caused by the given {@link Throwable}.
*
* <p>The exit code is generated by {@link CrashFailureDetails#detailedExitCodeForThrowable}.
+ * Notably, this results in a failure detail with either {@link
+ * com.google.devtools.build.lib.server.FailureDetails.Crash.Code#CRASH_OOM} or {@link
+ * com.google.devtools.build.lib.server.FailureDetails.Crash.Code#CRASH_UNKNOWN}. Crashes that
+ * deserve special handling should use {@link #from(Throwable, DetailedExitCode)} so that they can
+ * specify a custom {@link DetailedExitCode}.
*/
public static Crash from(Throwable throwable) {
return new Crash(throwable, CrashFailureDetails.detailedExitCodeForThrowable(throwable));
}
- /** Creates a crash caused by the given {@link Throwable} with a specified {@link ExitCode}. */
- // TODO(b/183140185): All callers should pass a DetailedExitCode. By passing just the plain
- // ExitCode, crashes are assigned the generic CRASH_UNKNOWN.
- public static Crash from(Throwable throwable, ExitCode exitCode) {
- return new Crash(
- throwable, DetailedExitCode.of(exitCode, CrashFailureDetails.forThrowable(throwable)));
- }
-
/**
* Creates a crash caused by the given {@link Throwable} with a specified {@link
* DetailedExitCode}.