From fd15fd52dfc6bb8f8e83e98d372b7f93e73a4fb6 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 28 Apr 2021 12:19:14 +0400 Subject: [PATCH] #27 -- fix exception handler --- .../extractor/config/GlobalDefaultExceptionHandler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/ru/ulstu/extractor/config/GlobalDefaultExceptionHandler.java b/src/main/java/ru/ulstu/extractor/config/GlobalDefaultExceptionHandler.java index c2df5cd..a5af0ec 100644 --- a/src/main/java/ru/ulstu/extractor/config/GlobalDefaultExceptionHandler.java +++ b/src/main/java/ru/ulstu/extractor/config/GlobalDefaultExceptionHandler.java @@ -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"; } } \ No newline at end of file