「Springboot入門」@ControllerAdviceでexceptionをカスタマイズする
Javaコード:
@ExceptionHandler({ RuntimeException.class })
@ResponseStatus(HttpStatus.OK)
public ModelAndView processException(RuntimeException exception) {
logger.info(“Custom exception -RuntimeException");
ModelAndView m = new ModelAndView();
m.addObject(“roncooException", exception.getMessage());
m.setViewName(“error/500");
return m;
}
@ExceptionHandler({ Exception.class })
@ResponseStatus(HttpStatus.OK)
public ModelAndView processException(Exception exception) {
logger.info(“Custom exception -Exception");
ModelAndView m = new ModelAndView();
m.addObject(“roncooException", exception.getMessage());
m.setViewName(“error/500");
return m;
}