|
@@ -4,16 +4,22 @@ import cn.hutool.core.exceptions.ExceptionUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.simuwang.base.common.exception.APIException;
|
|
import com.simuwang.base.common.exception.APIException;
|
|
import com.simuwang.base.common.exception.ErrorInfo;
|
|
import com.simuwang.base.common.exception.ErrorInfo;
|
|
|
|
+import com.smppw.common.pojo.enums.status.ResultCode;
|
|
import jakarta.servlet.ServletException;
|
|
import jakarta.servlet.ServletException;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.shiro.authc.AuthenticationException;
|
|
|
|
+import org.apache.shiro.authc.IncorrectCredentialsException;
|
|
|
|
+import org.apache.shiro.authc.UnknownAccountException;
|
|
import org.apache.shiro.authz.UnauthenticatedException;
|
|
import org.apache.shiro.authz.UnauthenticatedException;
|
|
import org.apache.shiro.authz.UnauthorizedException;
|
|
import org.apache.shiro.authz.UnauthorizedException;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.boot.context.properties.bind.validation.BindValidationException;
|
|
import org.springframework.core.Ordered;
|
|
import org.springframework.core.Ordered;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.http.converter.HttpMessageNotReadableException;
|
|
import org.springframework.lang.Nullable;
|
|
import org.springframework.lang.Nullable;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.servlet.HandlerExceptionResolver;
|
|
import org.springframework.web.servlet.HandlerExceptionResolver;
|
|
@@ -67,10 +73,16 @@ public class ErrorInfoBuilder implements HandlerExceptionResolver, Ordered {
|
|
msg = "请求资源找不到";
|
|
msg = "请求资源找不到";
|
|
} else if (error instanceof UnauthorizedException) {
|
|
} else if (error instanceof UnauthorizedException) {
|
|
msg = "没有对应接口的权限";
|
|
msg = "没有对应接口的权限";
|
|
|
|
+ } else if (error instanceof UnknownAccountException || error instanceof IncorrectCredentialsException) {
|
|
|
|
+ msg = ResultCode.AUTH_FAILD.getMsg();
|
|
|
|
+ } else if (error instanceof AuthenticationException) {
|
|
|
|
+ msg = "登录认证失败";
|
|
} else if (error instanceof APIException e) {
|
|
} else if (error instanceof APIException e) {
|
|
msg = e.getMsg();
|
|
msg = e.getMsg();
|
|
} else if (error instanceof UnauthenticatedException e) {
|
|
} else if (error instanceof UnauthenticatedException e) {
|
|
msg = e.getMessage();
|
|
msg = e.getMessage();
|
|
|
|
+ } else if (error instanceof HttpMessageNotReadableException || error instanceof BindValidationException) {
|
|
|
|
+ msg = "请求参数错误";
|
|
} else {
|
|
} else {
|
|
msg = error.getMessage();
|
|
msg = error.getMessage();
|
|
}
|
|
}
|