@Test
public void testSafeShutdownShutsDownIfHandlerThrowsError() throws Exception {

  try {
    SafeShutdown.exit(SafeShutdown.ExitCode.SAFE_SHUTDOWN, () -> {
      throw new AssertionError("This should not be the exception that appears");
    });
  } catch (IllegalStateException e) {
    assertThat(e).hasMessageThat().contains(SHUTDOWN_EXCEPTION_MESSAGE);
  }
}