#27 -- fix exception handler

merge-requests/27/head
Anton Romanov 3 years ago
parent 94e2dfbe2c
commit fd15fd52df

@ -5,6 +5,8 @@
package ru.ulstu.extractor.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ -18,10 +20,13 @@ import javax.servlet.http.HttpServletRequest;
@ControllerAdvice
@ApiIgnore
class GlobalDefaultExceptionHandler {
private final static Logger LOG = LoggerFactory.getLogger(GlobalDefaultExceptionHandler.class);
public static final String DEFAULT_ERROR_VIEW = "error";
@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) {
LOG.warn(e.getMessage());
ModelAndView mav = new ModelAndView();
mav.addObject("exception", e);
mav.addObject("url", req.getRequestURL());
@ -32,6 +37,7 @@ class GlobalDefaultExceptionHandler {
@ExceptionHandler(NoHandlerFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public String handle(NoHandlerFoundException ex) {
LOG.warn(ex.getMessage());
return "DEFAULT_ERROR_VIEW";
}
}
Loading…
Cancel
Save