#27 -- fix exception handler
This commit is contained in:
parent
94e2dfbe2c
commit
fd15fd52df
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
package ru.ulstu.extractor.config;
|
package ru.ulstu.extractor.config;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
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;
|
||||||
@ -18,10 +20,13 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
class GlobalDefaultExceptionHandler {
|
class GlobalDefaultExceptionHandler {
|
||||||
|
private final static Logger LOG = LoggerFactory.getLogger(GlobalDefaultExceptionHandler.class);
|
||||||
public static final String DEFAULT_ERROR_VIEW = "error";
|
public static final String DEFAULT_ERROR_VIEW = "error";
|
||||||
|
|
||||||
|
|
||||||
@ExceptionHandler(value = Exception.class)
|
@ExceptionHandler(value = Exception.class)
|
||||||
public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) {
|
public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) {
|
||||||
|
LOG.warn(e.getMessage());
|
||||||
ModelAndView mav = new ModelAndView();
|
ModelAndView mav = new ModelAndView();
|
||||||
mav.addObject("exception", e);
|
mav.addObject("exception", e);
|
||||||
mav.addObject("url", req.getRequestURL());
|
mav.addObject("url", req.getRequestURL());
|
||||||
@ -32,6 +37,7 @@ class GlobalDefaultExceptionHandler {
|
|||||||
@ExceptionHandler(NoHandlerFoundException.class)
|
@ExceptionHandler(NoHandlerFoundException.class)
|
||||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||||
public String handle(NoHandlerFoundException ex) {
|
public String handle(NoHandlerFoundException ex) {
|
||||||
|
LOG.warn(ex.getMessage());
|
||||||
return "DEFAULT_ERROR_VIEW";
|
return "DEFAULT_ERROR_VIEW";
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user