关于开发中异常自定义
/**
-
本系统自定义异常
-
@author datou
-
@Date: 2018/5/17 17:07
-
$
*/
public class AvaException extends RuntimeException {private static final long serialVersionUID = -140783351029584948L;
private int code;
public AvaException(String message) {
super(message);
this.code = -1;
}public AvaException(int code, String message) {
super(message);
this.code = code;
}public AvaException(int code, String message, Throwable cause) {
super(message, cause);
this.code = code;
}public int getCode() {
return code;
}
}
类似格式
if (bean != null) {
throw new AvatarException("登录名称已存在!");
}
if (bean1 != null) {
throw new AvatarException("用户名称已存在!");
}

浙公网安备 33010602011771号