Commit 6b148a16 authored by Maxym Borodenko's avatar Maxym Borodenko

Improve MVC logging

parent 6a81d5d7
Pipeline #2443 waiting for manual action with stages
in 2 minutes and 47 seconds
......@@ -27,6 +27,7 @@ import org.springframework.security.core.AuthenticationException;
import org.springframework.validation.Errors;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
......@@ -35,6 +36,8 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.NoHandlerFoundException;
import javax.servlet.http.HttpServletRequest;
@ControllerAdvice
public class UserControllerAdvice extends BaseController {
......@@ -63,8 +66,12 @@ public class UserControllerAdvice extends BaseController {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(value = { Throwable.class })
public ModelAndView handleAll(Throwable e) {
_logger.error(e.getMessage(), e);
public ModelAndView handleAll(HttpServletRequest req, Throwable e) {
if (e instanceof HttpRequestMethodNotSupportedException) {
_logger.error("Request method '" + ((HttpRequestMethodNotSupportedException) e).getMethod() + "' not supported for URL " + req.getRequestURL());
} else {
_logger.error(e.getMessage(), e);
}
final ModelAndView mav = new ModelAndView("/errors/error");
mav.addObject("exception", e);
return mav;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment