private String processException(Exception exp, int flag) {

    String message = "";
    String type = "";
    Date requestDate = null;
    Date reviewDate = null;

    switch (flag) {
      case 0:
        LoanProfile loanProfile = ((DuplicateLoanProfileException) exp).getLoanProfile();
        type = loanProfile.getProfileState().getCode();
        requestDate = loanProfile.getRequestDate();
        reviewDate = loanProfile.getReviewDate();
        break;

      case 1:
        ExchangeProfile exchangeProfile =
            ((DuplicateExchangeProfileException) exp).getExchangeProfile();
        type = exchangeProfile.getProfileState().getCode();
        requestDate = exchangeProfile.getRequestDate();
        reviewDate = exchangeProfile.getReviewDate();
        break;

      case 2:
        ProberProfile proberProfile = ((DuplicateProberProfileException) exp).getProberProfile();
        type = proberProfile.getProfileState().getCode();
        requestDate = proberProfile.getRequestDate();
        reviewDate = proberProfile.getReviewDate();
        break;
    }

    if (type.equalsIgnoreCase(ProfileState.NEW_REQUEST_STATE)) {

      message =
          JsfUtils.getStringFromBundle("yourRequestForUnit")
              + " "
              + JsfUtils.getStringFromBundle(this.selectedUnitOrLib.getName())
              + JsfUtils.getStringFromBundle("andMembershipAt")
              + " "
              + JsfUtils.getStringFromBundle(
                  UserManagementDataMap.convertRequestType(this.selectedRequestType))
              + JsfUtils.getStringFromBundle("inDate")
              + " "
              + String.valueOf(requestDate)
              + JsfUtils.getStringFromBundle("isRegisteredAndCurrentlyIsUnderProcessing");

    } else if (type.equalsIgnoreCase(ProfileState.CONFIRMED_REQUEST_STATE)) {

      message =
          JsfUtils.getStringFromBundle("yourRequestForUnit")
              + " "
              + JsfUtils.getStringFromBundle(this.selectedUnitOrLib.getName())
              + JsfUtils.getStringFromBundle("andMembershipAt")
              + " "
              + JsfUtils.getStringFromBundle(
                  UserManagementDataMap.convertRequestType(this.selectedRequestType))
              + JsfUtils.getStringFromBundle("inDate")
              + " "
              + String.valueOf(requestDate)
              + JsfUtils.getStringFromBundle("isRegisteredAndInDate")
              + " "
              + String.valueOf(reviewDate)
              + JsfUtils.getStringFromBundle("havebeenRejected")
              + JsfUtils.getStringFromBundle("wouldYouLikeToSubmitANewRequest");

    } else if (type.equalsIgnoreCase(ProfileState.REJECTED_REQUEST_STATE)) {

      message =
          JsfUtils.getStringFromBundle("yourRequestForUnit")
              + " "
              + JsfUtils.getStringFromBundle(this.selectedUnitOrLib.getName())
              + JsfUtils.getStringFromBundle("andMembershipAt")
              + " "
              + JsfUtils.getStringFromBundle(
                  UserManagementDataMap.convertRequestType(this.selectedRequestType))
              + JsfUtils.getStringFromBundle("inDate")
              + " "
              + String.valueOf(requestDate)
              + JsfUtils.getStringFromBundle("isConfirmed");

    } else assert true : "Invalid Profile State!!!";

    FacesContext context = FacesContext.getCurrentInstance();
    ViewHandler viewHandler = context.getApplication().getViewHandler();
    UIViewRoot dialog =
        viewHandler.createView(context, "/usermanagement/generalPages/showMessagePage.jspx");

    Map properties = new HashMap();
    properties.put("width", new Integer(300));
    properties.put("height", new Integer(400));

    Map params = new HashMap();
    params.put(UserManagementConstants.DIALOG_MESSAGE, message);
    RequestContext requestContext = RequestContext.getCurrentInstance();
    requestContext.launchDialog(dialog, params, null, true, properties);

    return "";
  }