对比新文件 |
| | |
| | | package com.gk.firework.Domain.Exception.Handler; |
| | | |
| | | import com.gk.firework.Domain.Exception.BusinessException; |
| | | import com.gk.firework.Domain.Utils.Msg; |
| | | import org.apache.log4j.LogManager; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.web.bind.annotation.ControllerAdvice; |
| | | import org.springframework.web.bind.annotation.ExceptionHandler; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | @ControllerAdvice |
| | | public class CustomExceptionHandler { |
| | | |
| | | private Logger logger = LogManager.getLogger(CustomExceptionHandler.class); |
| | | @ResponseBody |
| | | @ExceptionHandler(value = BusinessException.class) |
| | | public Msg errorHandler(Exception ex){ |
| | | logger.warn(ex); |
| | | Msg msg = new Msg(); |
| | | msg.setCode("400"); |
| | | msg.setMessage(ex.getMessage()); |
| | | return msg; |
| | | } |
| | | } |