SpringBoot统一异常处理
2020-10-27 本文已影响0人
小码A梦
@ControllerAdvice
public class ExceptionHandle {
private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle .class);
@ExceptionHandler(value = Exception.class)
@ResponseBody
public Result handle(Exception e){
Result result = OutUtil.error(e.getCode(), e.getMessage());
logger.error("business exception:" + result.getMessage() + "");
return result;
}
}