Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Created December 17, 2013 21:08
Show Gist options
  • Save dwelch2344/8012646 to your computer and use it in GitHub Desktop.
Save dwelch2344/8012646 to your computer and use it in GitHub Desktop.
@Slf4j
@ControllerAdvice
public class ControllerConfig {
@ExceptionHandler(Exception.class)
public ModelAndView handleException(Exception ex, HttpServletResponse response) {
log.warn("Unchaught Exception", ex);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
// TODO handle AJAX calls differently
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("error");
modelAndView.addObject("errorName", ex.getClass().getSimpleName());
return modelAndView;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment