Allow passing a `DetailedExitCode` to `Crash`. There's really not much reason to pass just a custom `ExitCode` without `FailureDetail` since it will just be assigned the generic `CRASH_UNKNOWN`. Left a `TODO` to clean this up.
@@ -33,11 +33,21 @@ public final class Crash {
}
/** 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}.
+ */
+ public static Crash from(Throwable throwable, DetailedExitCode detailedExitCode) {
+ return new Crash(throwable, detailedExitCode);
+ }
+
private final Throwable throwable;
private final DetailedExitCode detailedExitCode;
