Merge pull request #111 from idranme/main

fix: error catch
This commit is contained in:
手瓜一十雪 2024-07-10 11:55:53 +08:00 committed by GitHub
commit 30d260ab32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -160,7 +160,12 @@ export async function httpDownload(options: string | HttpDownloadOptions): Promi
}
}
}
const fetchRes = await fetch(url, { headers });
const fetchRes = await fetch(url, { headers }).catch((err) => {
if (err.cause) {
throw err.cause;
}
throw err;
});
if (!fetchRes.ok) throw new Error(`下载文件失败: ${fetchRes.statusText}`);
const blob = await fetchRes.blob();