Search in sources :

Example 1 with AuthorizedUser

use of ru.javawebinar.topjava.AuthorizedUser in project topjava10 by JavaWebinar.

the class GlobalControllerExceptionHandler method defaultErrorHandler.

@ExceptionHandler(Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
    LOG.error("Exception at request " + req.getRequestURL(), e);
    ModelAndView mav = new ModelAndView("exception/exception");
    mav.addObject("exception", e);
    // Interceptor is not invoked, put userTo
    AuthorizedUser authorizedUser = AuthorizedUser.safeGet();
    if (authorizedUser != null) {
        mav.addObject("userTo", authorizedUser.getUserTo());
    }
    return mav;
}
Also used : AuthorizedUser(ru.javawebinar.topjava.AuthorizedUser) ModelAndView(org.springframework.web.servlet.ModelAndView) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Aggregations

ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 AuthorizedUser (ru.javawebinar.topjava.AuthorizedUser)1