取消exception全局捕获
This commit is contained in:
parent
ab6cf6661a
commit
54f04bcde3
@ -14,7 +14,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.authentication.InsufficientAuthenticationException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@ -42,11 +41,8 @@ public class ResponseAdvice {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ResponseAdvice.class);
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler({SystemException.class, SQLSyntaxErrorException.class, Exception.class, HashMapUtil.TypeConversionException.class, ReflectUtil.ReflectException.class})
|
||||
public void responseException(HttpServletRequest request, HttpServletResponse response, Exception e) throws IOException {
|
||||
if (e instanceof InsufficientAuthenticationException) {
|
||||
throw new InsufficientAuthenticationException(e.getMessage());
|
||||
}
|
||||
@ExceptionHandler({SystemException.class, SQLSyntaxErrorException.class, HashMapUtil.TypeConversionException.class, ReflectUtil.ReflectException.class})
|
||||
public void responseException(HttpServletRequest request, HttpServletResponse response, Exception e) throws IOException, ServletException {
|
||||
if (e instanceof FileException) {
|
||||
LOG.error(e.getMessage());
|
||||
} else if (e instanceof ParamsException) {
|
||||
@ -115,16 +111,11 @@ public class ResponseAdvice {
|
||||
if (!response.isCommitted()) {
|
||||
StackTraceElement[] stackTraces = e.getStackTrace();
|
||||
List<String> errorStackTraces = new ArrayList();
|
||||
for(StackTraceElement stackTraceElement: stackTraces) {
|
||||
for (StackTraceElement stackTraceElement : stackTraces) {
|
||||
errorStackTraces.add(stackTraceElement.toString());
|
||||
}
|
||||
try {
|
||||
request.getSession().setAttribute("errorStackTraces", errorStackTraces);
|
||||
request.getRequestDispatcher("/error/exception").forward(request, response);
|
||||
} catch (IOException | ServletException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
return;
|
||||
request.getSession().setAttribute("errorStackTraces", errorStackTraces);
|
||||
request.getRequestDispatcher("/error/exception").forward(request, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user