自定义异常

1.自定义异常

public class CreateFailedException extends RuntimeException{

    public CreateFailedException(String errMsg) {
        super(errMsg);
    }

    /**
     * Construct a new runtime exception with the cause
     *
     * @param cause cause
     */
    public CreateFailedException(Throwable cause) {
        super(cause);
    }

    /**
     * Construct a new runtime exception with the detail message and cause
     *
     * @param errMsg message
     * @param cause cause
     */
    public CreateFailedException(String errMsg, Throwable cause) {
        super(errMsg, cause);
    }
	
	public static void fail(String message) {
        throw new CreateFailedException(message);
    }
}
posted @ 2021-06-01 11:25  SpecialSpeculator  阅读(43)  评论(0编辑  收藏  举报