处理Exception捕获导致客户端无法正常跳转问题
This commit is contained in:
parent
1559eff981
commit
9a3fb3e060
@ -10,6 +10,8 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.security.authentication.InsufficientAuthenticationException;
|
||||||
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
@ -36,6 +38,9 @@ public class ResponseAdvice {
|
|||||||
@ExceptionHandler({SystemException.class, SQLSyntaxErrorException.class, Exception.class})
|
@ExceptionHandler({SystemException.class, SQLSyntaxErrorException.class, Exception.class})
|
||||||
public void responseException(HttpServletRequest request, HttpServletResponse response, Exception e) throws IOException {
|
public void responseException(HttpServletRequest request, HttpServletResponse response, Exception e) throws IOException {
|
||||||
LOG.error(e.getMessage(), e);
|
LOG.error(e.getMessage(), e);
|
||||||
|
if (e instanceof InsufficientAuthenticationException) {
|
||||||
|
throw new InsufficientAuthenticationException(e.getMessage());
|
||||||
|
}
|
||||||
ErrorResult result = new ErrorResult(ErrorResultCodeEnum.SYSTEM_ERROR.getValue(), "系统错误");
|
ErrorResult result = new ErrorResult(ErrorResultCodeEnum.SYSTEM_ERROR.getValue(), "系统错误");
|
||||||
if (e instanceof SaveException) {
|
if (e instanceof SaveException) {
|
||||||
result.setCode(ErrorResultCodeEnum.SAVE_ERROR.getValue());
|
result.setCode(ErrorResultCodeEnum.SAVE_ERROR.getValue());
|
||||||
|
Loading…
Reference in New Issue
Block a user