@Override
    public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
        LeaveGroupResponseData responseData = new LeaveGroupResponseData()
                                                  .setErrorCode(Errors.forException(e).code());

        if (version() >= 1) {
            responseData.setThrottleTimeMs(throttleTimeMs);
        }
        return new LeaveGroupResponse(responseData);
    }
Based on the request version to choose fields.
clients/src/main/java/org/apache/kafka/common/requests/LeaveGroupRequest.java