【公共规范】对于出错信息,要进行详细说明
对于出错信息要进行详细的说明(安全/隐私信息除外),说明为什么错了,而不只是说出错了。
举例:
if (checkOrderQuantityParam.getOrderQuantity() + totalCount > checkOrderQuantityParam.getLimitQuantity()) {
throw new CheckException("当前商品购买数量超过限购数量");
}
详细:
final int orderQuantity = checkOrderQuantityParam.getOrderQuantity();
final int limitQuantity = checkOrderQuantityParam.getLimitQuantity();
final int purchase = orderQuantity + totalCount;
if (purchase > limitQuantity)) {
throw new CheckException("当前商品购买总数(" + purchase + "。其中已购买" + totalCount + ",当前下单" + orderQuantity + ")超过限购数量
}
再详细:
final int orderQuantity = checkOrderQuantityParam.getOrderQuantity();
final int limitQuantity = checkOrderQuantityParam.getLimitQuantity();
final int purchase = orderQuantity + totalCount;
if (purchase > limitQuantity)) {
throw new CheckException(String.format("当前商品购买总数($d。其中已购买%d,当前下单%d)超过限购数量(%d)", purchase, totalCount, order
}