报错注意:
1、在自定义realm类中,抛出的异常会被Authenticationexception打包
同时会被shiroexception抓住:
使用e.getCause获取
2、由shiro抛出的错误可以:
如果其中一个现有异常类不满足您的需求,AuthenticationExceptions则可以创建自定义以表示特定的故障方案。
以下为shiro的自带异常:
的异常全是shiro执行时候可以抛出的,对应字面意思
public FsResultJson doHandleShiroException(
ShiroException e) {
FsResultJson r = new FsResultJson(e);
r.setStauts(0);
if (e.getCause() instanceof UnknownAccountException) {
r.setMessage("账户不存在");
} else if (e.getCause() instanceof LockedAccountException) {
r.setMessage("账户已被禁用");
} else if (e instanceof IncorrectCredentialsException) {
r.setMessage("用户名或密码不正确");
} else if (e.getCause() instanceof AuthorizationException) {
r.setMessage("亲爱的会员用户,请先激活再登录");
} else {
r.setMessage("系统维护中......");
}
e.printStackTrace();
return r;
}