统一异常处理类

阅读 64

2022-02-08

每个项目都应该定义一个异常抛出的机制。

模板类:

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("名称不能为空");
    }
}

精彩评论(0)

0 0 举报