@Override
    public RuntimeException handleFault(String failureMessage, Throwable cause) {
        if (cause == null) {
            log.error("Encountered fatal fault: {}", failureMessage);
        } else {
            log.error("Encountered fatal fault: {}", failureMessage, cause);
        }

        try {
            action.run();
        } catch (Throwable e) {
            log.error("Failed to run terminating action.", e);
        }

        int statusCode = 1;
        if (shouldHalt) {
            Exit.halt(statusCode);
        } else {
            Exit.exit(statusCode);
        }

        return null;
    }
@Test
    public void testHaltIsCalled() {
        AtomicBoolean haltCalled = new AtomicBoolean(false);
        Exit.setHaltProcedure(terminatingProcedure(haltCalled));

        AtomicBoolean actionCalled = new AtomicBoolean(false);
        Runnable action = () -> {
            assertFalse(haltCalled.get());
            actionCalled.set(true);
        };

        try {
            new ProcessTerminatingFaultHandler.Builder()
                .setAction(action)
                .build()
                .handleFault("", null);
        } finally {
            Exit.resetHaltProcedure();
        }

        assertTrue(haltCalled.get());
        assertTrue(actionCalled.get());
    }