每个项目都应该定义一个异常抛出的机制。
模板类:
public class customExceptionHandle extends RuntimeException {
public customExceptionHandle(String message) {
super(message);
}
public customExceptionHandle(String message, Throwable cause) {
super(message, cause);
}
}
调用:
public String transferOrderNoOneOnOne(String name) {
if (name == null) {
throw new SmartAllocatException("名称不能为空");
}
}