fix: 报错统一改为简短中文 - #63
Merged
Merged
Conversation
This was referenced Sep 24, 2026
- hub 的错误回复只有两个出口:写好的中文文案原样返回;其余错误记进日志, 面板只显示「hub 内部出错,详细原因见 hub 日志」。axum 自带的拒绝文案由 中间件换成按状态码的中文说明。 - 英文校验提示全部改成中文;回给 install.sh 与 agent 的保持英文。 - 主题包读到一半中断(截断、不是 gzip)提示重新下载,不再显示解压库原文与 服务器路径。 - 通知测试、GitHub 登录、主题更新:第三方的回复按状态码写成中文原因,原文进日志。 - 面板:反代或 CDN 的错误页、断网、200 却不是 JSON,都按状态给中文说明。
stqfdyr
force-pushed
the
fix/error-messages
branch
from
September 24, 2026 18:46
d8f9b5a to
a6d7977
Compare
- install.sh 与 agent 用的四条路由合并在改写中间件之后,axum 的拒绝保持英文; 中间件只换正文,保留原响应头(如 405 的 Allow)。 - GitHub 登录与主题更新:GitHub 回了但内容读不懂时不再说成「连不上」; /user 返回非用户信息时带上状态码。 - 主题包里同名的文件与目录、过长的文件名给出包的问题,不再是内部错误。 - 探测任务只在外键失败时说「节点不存在」,其余数据库错误按内部错误处理。 - 上传中途断开提示重新上传,只记 info。 - 通知数值设置的名称写进 NUMBERS 表。
stqfdyr
added a commit
to monitor-probe/monitor-theme-default
that referenced
this pull request
Sep 24, 2026
- `api()`:只把 `text/plain` 的错误回复当 hub 的话原样显示;反代或 CDN 的错误页(如 nginx 的 502、Cloudflare 的拦截页)不再把 HTML 显示给访客,按状态码说明「服务暂时无法访问」或「请求被拦截」 - 断网提示「网络连接失败,稍后再试」;返回 200 却不是 JSON 提示「收到的不是状态数据」 - 错误信息不再可能是空串,去掉 `App.tsx`、`NodeDetail.tsx` 两处 `|| "网络错误"` 兜底 配合 monitor-probe/monitor#63:hub 的错误回复改为一行中文纯文本。 ## 测试 - `tsc -b`、`oxlint`、`npm test` 通过 - 打包装进临时 hub 后浏览器实测:`/api/me` 返回 HTML 502、断网、200 网页三种情况,首页都显示中文提示与重试按钮
stqfdyr
added a commit
to monitor-probe/monitor-theme-serverstatus
that referenced
this pull request
Sep 24, 2026
- `api()`:只把 `text/plain` 的错误回复当 hub 的话原样显示;反代或 CDN 的错误页(如 nginx 的 502、Cloudflare 的拦截页)不再把 HTML 显示给访客,按状态码说明「服务暂时无法访问」或「请求被拦截」 - 断网提示「网络连接失败,稍后再试」;返回 200 却不是 JSON 提示「收到的不是状态数据」 - 错误信息不再可能是空串,去掉 `App.tsx`、`NodeDetail.tsx` 两处 `|| "网络错误"` 兜底 配合 monitor-probe/monitor#63:hub 的错误回复改为一行中文纯文本。 ## 测试 - `tsc -b`、`oxlint`、`npm test` 通过
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hub
api::answer/bad返回写好的文案;其余错误交给api::fail。错误链上有Shown(refuse!或.context(Shown(..)))就回 400 带那句话,没有就把整条链记 warn,回 500「hub 内部出错,详细原因见 hub 日志」api::plain_errors兜住 hub 没有自己写文案的错误回复(axum 的 JSON / 路径 / 参数拒绝、请求体上限 413、空的 401 / 404),按状态码换成中文,只换正文,原响应头保留(如 405 的Allow)/api/agent/ws、/api/agent/register、/install.sh、/agent/{arch})合并在中间件之后,回给它们的报错保持英文,与脚本和 agent 自己的输出一致not delivered);渠道名显示为 Telegram / Webhook;数值设置的名称写进NUMBERS表面板
api()/upload():只把text/plain的错误回复当 hub 的话;反代或 CDN 的 HTML 错误页、不带 Content-Type 的回复按状态码说明,断网提示「连不上 hub」,200 却不是 JSON 提示检查/api的转发测试
cargo fmt --check、cargo clippy --all-targets、cargo test(126 个)、scripts/e2e.sh;tsc -b、oxlint、npm test通过Allow;注册接口与 agent 握手的 axum 拒绝保持英文Bad Gateway、不带 Content-Type,面板按状态码说明