Skip to content

Commit 6b06e17

Browse files
author
florian
committed
fix: added error handling for failing uploads
1 parent 35c1967 commit 6b06e17

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/upload.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,19 @@ export async function processUploads(
3636
lastModified: f.changedAt,
3737
});
3838

39-
const uploads = multiServerUpload(blossomServers, file, signEventTemplate);
40-
// TODO better error handling for 400, 402, 5xx ... for individual blossom servers
41-
// TODO also test for servers that are not accessible
42-
let published = false;
43-
for await (const { blob, progress, server } of uploads) {
44-
console.log("Uploaded", f.remotePath, `${server}/${blob.sha256}`);
45-
if (!published) {
46-
await publishNSiteEvent(ndk, pubkey, f.remotePath, f.sha256);
39+
try {
40+
const uploads = multiServerUpload(blossomServers, file, signEventTemplate);
41+
// TODO better error handling for 400, 402, 5xx ... for individual blossom servers
42+
// TODO also test for servers that are not accessible
43+
let published = false;
44+
for await (const { blob, progress, server } of uploads) {
45+
console.log("Uploaded", f.remotePath, `${server}/${blob.sha256}`);
46+
if (!published) {
47+
await publishNSiteEvent(ndk, pubkey, f.remotePath, f.sha256);
48+
}
4749
}
50+
} catch (err) {
51+
console.error(`Error uploading '${file}'`, err);
4852
}
4953
}
5054

0 commit comments

Comments
 (0)