资源编辑 400 同时透出平台错误码
- editor_api_rejection_reason 额外读取响应体 error.code,过滤掉等价于通用文案的 BAD_REQUEST 后拼成「原因|错误码 CODE」 - 背景:http_error.rs 把所有 4xx 兜底为同一条「请求参数不合法」,只透 message 会丢掉唯一可用于定位的信息
This commit is contained in:
@@ -2483,7 +2483,19 @@ async fn editor_api_rejection_reason(response: reqwest::Response) -> Option<Stri
|
|||||||
if trimmed.is_empty() {
|
if trimmed.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(trimmed.chars().take(200).collect())
|
// 平台把所有 4xx 都兜底成同一条通用文案(`http_error.rs`),真实原因在 `error.code` 里,
|
||||||
|
// 因此稳定码必须一起透出,否则用户和排障者只能看到"请求参数不合法"。
|
||||||
|
let code = value
|
||||||
|
.get("error")
|
||||||
|
.and_then(|error| error.get("code"))
|
||||||
|
.and_then(|code| code.as_str())
|
||||||
|
.map(str::trim)
|
||||||
|
.filter(|code| !code.is_empty() && *code != "BAD_REQUEST");
|
||||||
|
let reason: String = trimmed.chars().take(200).collect();
|
||||||
|
Some(match code {
|
||||||
|
Some(code) => format!("{reason}|错误码 {code}"),
|
||||||
|
None => reason,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn submit_resource_edit_remote(
|
async fn submit_resource_edit_remote(
|
||||||
|
|||||||
Reference in New Issue
Block a user