描述 bug
后端返回的报错为:
{
"code": 10030,
"message": "请求体不可为空",
"request": "PUT /cms/admin/user/2"
}
(截图为”管理员更新用户信息”的接口请求)

{
"code": 10030,
"message": "group_ids字段类型错误",
"request": "PUT /cms/admin/user/2"
}
请求体不可为空的报错信息非常模糊,对前端误导性极强。
你使用哪个版本出现该问题?
如果使用master,请表明是 master 分支,否则给出具体的版本号
master 分支,0.2.0-RC2 版本。
If your bug is deterministic, can you give a minimal reproducing code?
Some bugs are not deterministic. Can you describe with precision in which context it happened?
If this is possible, can you share your code?
修改如下代码:
|
@ExceptionHandler({HttpMessageNotReadableException.class}) |
|
public UnifyResponseVO processException(HttpMessageNotReadableException exception, HttpServletRequest request, HttpServletResponse response) { |
|
log.error("", exception); |
|
UnifyResponseVO result = new UnifyResponseVO(); |
|
result.setRequest(getSimpleRequest(request)); |
|
String errorMessage = CodeMessageConfiguration.getMessage(10170); |
|
if (StrUtil.isBlank(errorMessage)) { |
|
result.setMessage(exception.getMessage()); |
|
} else { |
|
result.setMessage(errorMessage); |
|
} |
|
result.setCode(Code.PARAMETER_ERROR.getCode()); |
|
response.setStatus(HttpStatus.BAD_REQUEST.value()); |
|
return result; |
|
} |
描述 bug
你是如何操作的?
后端接口的 DTO 对象中定义一个列表类型参数;前端故意将参数类型传错,把请求 body 里面的列表类型参数改为整型或字符串类型。
发生了什么?
后端返回的报错为:
{ "code": 10030, "message": "请求体不可为空", "request": "PUT /cms/admin/user/2" }(截图为”管理员更新用户信息”的接口请求)

应该出现如下报错:
{ "code": 10030, "message": "group_ids字段类型错误", "request": "PUT /cms/admin/user/2" }请求体不可为空的报错信息非常模糊,对前端误导性极强。
你使用哪个版本出现该问题?
如果使用
master,请表明是 master 分支,否则给出具体的版本号master 分支,0.2.0-RC2 版本。
If your bug is deterministic, can you give a minimal reproducing code?
Some bugs are not deterministic. Can you describe with precision in which context it happened?
If this is possible, can you share your code?
修改如下代码:
lin-cms-spring-boot/src/main/java/io/github/talelin/latticy/common/exception/RestExceptionHandler.java
Lines 191 to 205 in bd6b0c8