hmjz100/LinkSwift · error · Error
[天翼云盘] 获取文件 URL 失败
Error message
[天翼云盘] 获取文件 URL 失败
What it means
A wrapper error thrown in the 天翼云盘 (Tianyi Cloud) getLink batch flow when a per-file getFileUrl promise rejects with a non-Error value. The catch handler re-wraps whatever rejection value it received (or a plain string) into a standardized Error with the message '[天翼云盘] 获取文件 URL 失败' so downstream UI code can display a uniform failure message. It is a normalization wrapper, not the root cause itself.
Source
Thrown at (改)网盘直链下载助手.user.js:7394
const batchSize = 15;
let proc = 0;
$doc.find(".loading-popup .loading-title").html(`链接获取中`);
$doc.find(".loading-popup .swal2-html-container").html(`<div>正在获取文件对应的下载链接~</div>`);
for (let i = 0; i < selects.length; i += batchSize) {
const batch = selects.slice(i, i + batchSize);
const queue = [];
batch.forEach((item, localIndex) => {
const globalIndex = i + localIndex;
queue.push(this.getFileUrl(item, globalIndex, token)
.then(val => {
proc++;
$doc.find(".loading-popup .swal2-html-container").html(`<div>已获取 ${proc} / ${selects.length} 个链接~</div>`);
return val;
}));
});
const res = await Promise.all(queue).catch(e => {
if (e instanceof Error) throw e;
throw new Error(e?.message || e || "[天翼云盘] 获取文件 URL 失败");
});
res.forEach(val => {
selects[val.index].downloadUrl = val.downloadUrl;
});
await base.sleep(1000);
}
temp.links = [selects, {
isFolder: v => v.isFolder,
getFileName: v => v.fileName,
getFileSize: v => v.size,
getFileLink: v => v.downloadUrl,
tooltip: config.$mcloud.dom
}];
base.showMainDialog(config.base.dom.button[temp.mode].title, base.generateDOM(temp.links), config.base.dom.button[temp.mode].footer);
},
getSelectedList() {
try {
return document.querySelector(".c-file-list").__vue__.selectedList;
View on GitHub (pinned to 417ea5e28a)
Solutions
- Re-login to 天翼云盘 in the userscript so credentials/captcha tokens are refreshed, then retry link fetching
- Inspect the console for the original rejection value logged before the wrapper replaces it, and address that root cause
- Retry with fewer files selected to isolate which specific file(s) fail and exclude them
- Update the userscript if the cloud API contract changed; ensure getFileUrl always throws Error instances so the real message is preserved
Example fix
// before (anywhere in the flow)
reject({ code: 500 });
// after
reject(new Error("获取下载地址失败: " + JSON.stringify({ code: 500 }))); Defensive patterns
Strategy: try-catch
Validate before calling
// before getLink
const ready = await isTianyiLoggedIn();
if (!ready) { promptLogin(); return; } Type guard
function isError(e) { return e instanceof Error; } Try / catch
try { await getLink(); } catch (e) { if (/天翼云盘.*获取文件 URL 失败/.test(e.message)) { showToast('部分文件链接获取失败,请重新登录天翼云盘后重试'); } else throw e; } Prevention
- Re-login when sessions are stale
- Select fewer files per batch to limit blast radius
- Always throw Error instances in underlying fetch helpers
- Log original rejections before wrapping
When it happens
Trigger: Batch download link retrieval in getLink(): Promise.all(queue) rejects with a non-Error rejection value — e.g. getFileUrl threw a plain string, an object like {message}, or undefined/null — during processing of a batch of up to 15 selected files via the Tianyi API.
Common situations: Expired or invalid Tianyi login session causing underlying getFileUrl to reject with a raw server response object; network timeouts returning non-Error values; API response shape changes after a cloud-side update; selecting files whose share/download permission was revoked mid-batch.
Related errors
AI-assisted analysis of hmjz100/LinkSwift@417ea5e28a (2026-09-02).
Data as JSON: /api/errors/21d4c54dd0ca5181.
Report an issue: GitHub.