private void handleResponse(RaftResponse.Inbound response, long currentTimeMs) {
        // The response epoch matches the local epoch, so we can handle the response
        ApiKeys apiKey = ApiKeys.forId(response.data().apiKey());
        final boolean handledSuccessfully;

        switch (apiKey) {
            case FETCH:
                handledSuccessfully = handleFetchResponse(response, currentTimeMs);
                break;

            case VOTE:
                handledSuccessfully = handleVoteResponse(response, currentTimeMs);
                break;

            case BEGIN_QUORUM_EPOCH:
                handledSuccessfully = handleBeginQuorumEpochResponse(response, currentTimeMs);
                break;

            case END_QUORUM_EPOCH:
                handledSuccessfully = handleEndQuorumEpochResponse(response, currentTimeMs);
                break;

            case FETCH_SNAPSHOT:
                handledSuccessfully = handleFetchSnapshotResponse(response, currentTimeMs);
                break;

            case API_VERSIONS:
                handledSuccessfully = handleApiVersionsResponse(response, currentTimeMs);
                break;

            default:
                throw new IllegalArgumentException("Received unexpected response type: " + apiKey);
        }

        requestManager.onResponseResult(
            response.source(),
            response.correlationId(),
            handledSuccessfully,
            currentTimeMs
        );
    }
Handle response errors that are common across request types.

@param error Error from the received response
@param leaderId Optional leaderId from the response
@param epoch Epoch received from the response
@param leaderEndpoints the endpoints of the leader from the response
@param source the node that sent the response
@param currentTimeMs Current epoch time in milliseconds
@return Optional value indicating whether the error was handled here and the outcome of
   that handling. Specifically:

   - Optional.empty means that the response was not handled here and the custom
       API handler should be applied
   - Optional.of(true) indicates that the response was successfully handled here and
       the node can become ready
   - Optional.of(false) indicates that the response was handled here, but that the
       node should got in to backoff
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java