catch异常

int ret = -1;
try {
ret = tBuyerCodeApplyInfoService.insertTBuyerCodeApplyInfoBySelective(buyerCode);
} catch (Exception e) {
boolean find = false;
Throwable exception = e;
while (exception != null ) {
if(exception instanceof MySQLIntegrityConstraintViolationException){
find = true;
break;
} else {
exception = exception.getCause();
}
}
if(!find) {
throw e;
} else {
return "请勿重复提交";
}
}

原文地址:https://www.cnblogs.com/knightsu/p/7879371.html