final Throwable realCause = dve.getMostSpecificCause();
if (realCause.getMessage().contains("sa_account_no_UNIQUE")) {
final String accountNo = command.stringValueOfParameterNamed("accountNo");
errorCodeBuilder.append(".duplicate.accountNo");
throw new PlatformDataIntegrityException(errorCodeBuilder.toString(), "Savings account with accountNo " + accountNo
+ " already exists", "accountNo", accountNo);
} else if (realCause.getMessage().contains("sa_external_id_UNIQUE")) {
final String externalId = command.stringValueOfParameterNamed("externalId");
errorCodeBuilder.append(".duplicate.externalId");
throw new PlatformDataIntegrityException(errorCodeBuilder.toString(), "Savings account with externalId " + externalId
+ " already exists", "externalId", externalId);
}
errorCodeBuilder.append(".unknown.data.integrity.issue");
logger.error(dve.getMessage(), dve);
throw new PlatformDataIntegrityException(errorCodeBuilder.toString(), "Unknown data integrity issue with savings account.");
}