fix(mount): shorter generic WebDAV error copy

This commit is contained in:
noelorin 2026-09-27 17:12:00 +08:00
parent e1778520ed
commit 96b3d8679b
1 changed files with 5 additions and 9 deletions

View File

@ -209,16 +209,14 @@ export const mountService = {
function describeWebdavError(e: unknown, path?: string): string {
const raw = e instanceof Error ? e.message : String(e);
const s = raw.toLowerCase();
const pathHint = path ? `(路径 ${path})` : "";
if (
s.includes("401") ||
s.includes("403") ||
s.includes("unauthorized") ||
s.includes("forbidden") ||
s.includes("not authorized")
) {
return `认证失败(服务器拒绝该账号/密码)${pathHint}。请核对飞牛「WebDAV」专用账号密码(常与网页登录不同),并确认地址是否带 /dav 前缀`;
}
)
return "认证失败,请检查用户名和密码";
if (s.includes("enotfound") || s.includes("eai_again") || s.includes("getaddrinfo"))
return "无法解析服务器地址";
if (s.includes("econnrefused")) return "连接被拒绝,请检查地址和端口";
@ -226,12 +224,10 @@ function describeWebdavError(e: unknown, path?: string): string {
return "连接超时";
if (s.includes("certificate") || s.includes("ssl") || s.includes("tls"))
return "HTTPS 证书错误";
if (s.includes("400") || s.includes("bad request"))
return `HTTP 400:服务器拒绝该请求${pathHint}。请确认 WebDAV 地址含正确前缀(如 http://主机:端口/dav),根路径为共享目录且 URL 可用`;
if (s.includes("400") || s.includes("bad request")) return "请求被拒绝,请检查地址和根路径";
if (s.includes("404") || s.includes("405") || s.includes("not found"))
return `地址或路径不存在${pathHint}(可能不是 WebDAV 服务,或根路径不正确)`;
const short = raw.length > 120 ? `${raw.slice(0, 120)}…` : raw;
return `连接失败:${short}`;
return "路径不存在,请检查 WebDAV 地址和根路径";
return "连接失败";
}
/**