62,614
社区成员
发帖
与我相关
我的任务
分享
两年多后的今天,我也出现了这个问题。没收到解决方法。 我试着返回一个字符串,发现APIFox是可以接到返回消息的, 然后我就想是不是返回类型不是bean啊? 结果一看,没有加@Data。
/**
* @author liuyh
* @Description:
* @date 2020/9/2214:13
*/
@ControllerAdvice
@Slf4j
public class ExceptionError {
@ExceptionHandler(value = Exception.class)
@ResponseBody
public Result defaultErrorHandler(HttpServletRequest req, HttpServletResponse resp, Exception e) {
e.printStackTrace();
Result resul = new Result();
if (e instanceof HttpRequestMethodNotSupportedException) {
resul.setResltInfo(Constant.CODE_TYPE_10, "非法请求", e.getMessage());
} else if (e instanceof HystrixRuntimeException) {
resul.setResltInfo(Constant.CODE_TYPE_30, "feign调用系统异常", e.getCause().getMessage());
} else {
resul.setResltInfo(Constant.CODE_TYPE_1, "系统异常", e.getMessage());
}
return resul;
}
}