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