自定义异常
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);
}
}
原创:做时间的朋友