/** * <> * < Error interception return json To the caller > * * @Author jason_w * @Date 2019/1/9 0009 21:27 *
@see */ @ControllerAdvice public class ExceptionHandlerAdvice { private static
final Logger LOGGER = LoggerFactory.getLogger(ExceptionHandlerAdvice.class);
/** *< Exception returns to the previous paragraph JSON data , Error handling based on front end > *@param * *@return *@Author jason_wang */
@ExceptionHandler(value = Exception.class) @ResponseBody public String
exception(Exception ex, WebRequest request)throws Exception{
LOGGER.error("ExceptionHandlerAdvice Intercept exception ,e:{}",ex.getMessage()); Result
pageList=new Result(); pageList.setCode(1); if (ex instanceof
UnauthorizedException){ pageList.setMsg(" You do not have permission to do this "); }else if (ex instanceof
AppException){ pageList.setMsg(ex.getMessage()); }else {
pageList.setMsg(" Unknown exception "); } return new
ObjectMapper().writeValueAsString(pageList); } @ModelAttribute public void
AddAttribute(Model model){ model.addAttribute("user", SubjectUtil.getUser()); }

©2020 ioDraw All rights reserved
Using genetic algorithm to solve function optimization problem ( Single target )CLion Novice step on the pit :CMake project is not loaded Google says home office affects work efficiency !2021 Return to offline office in 2010 Data analysis interview experience ( Give yourself a process of carding )C Language implementation of simple minesweeping ( It's all dry goods , Novice Xiaobai must see )Python Basic knowledge !!C Language implementation of minesweeping game Valentine's Day , rose , The one in your heart ~ Operation and maintenance work Python Painting cherry blossoms