【发布时间】:2019-07-04 21:27:18
【问题描述】:
我的应用程序有一个服务,其中 3 个方法执行一些验证,并根据返回的结果引发不同的异常。
if (!check1stCondition() {
throw new ValidationException(message1);
}
if (!check2ndCondition)
throw new ValidationException(message2);
if (!check3rdCondition)
throw new ValidationException(message3);
}
如何重新格式化此代码以便将来可维护?将来可能会执行新的检查。
【问题讨论】:
标签: java if-statement exception reformat