private ChallengeQuestionIdsDTO handleChallengeIdError(String error, Exception e) {

    ChallengeQuestionIdsDTO bean = new ChallengeQuestionIdsDTO();

    if (error != null) {
      bean.setError(error);
      log.error(error, e);
    } else {
      bean.setError(e.getMessage());
      log.error(e.getMessage(), e);
    }

    return bean;
  }
  public ChallengeQuestionIdsDTO getUserChallengeQuestionIds(String username, String confirmation)
      throws IdentityMgtServiceException {

    UserDTO userDTO = null;
    ChallengeQuestionIdsDTO idsDTO = new ChallengeQuestionIdsDTO();

    if (log.isDebugEnabled()) {
      log.debug("User challenge questions id request received with username: "******"Error while getting challenge question ids for user : "******"Error when validating code", e1);
        return idsDTO;
      }
      if (bean.isVerified()) {
        try {
          idsDTO =
              processor
                  .getQuestionProcessor()
                  .getUserChallengeQuestionIds(userDTO.getUserId(), userDTO.getTenantId());
          idsDTO.setKey(bean.getKey());
          if (log.isDebugEnabled()) {
            log.debug("User challenge question response successful for user: "******"Error when getting user challenge questions for user : "******"Verification failed for user. Error : " + bean.getError();
        log.error(msg);
        idsDTO.setError(VerificationBean.ERROR_CODE_UNEXPECTED + " " + msg);
        idsDTO.setKey("");
      }
    } finally {
      if (IdentityMgtConfig.getInstance().isSaasEnabled()) {
        PrivilegedCarbonContext.endTenantFlow();
      }
    }

    return idsDTO;
  }