improving ntfy error handling

This commit is contained in:
orangecoding
2025-10-06 20:19:53 +02:00
parent f0f1244baa
commit 2e537ce0be

View File

@@ -36,6 +36,16 @@ Link: ${newListing.link}`;
method: 'POST', method: 'POST',
headers, headers,
body: message, body: message,
})
.then((res) => {
if (!res.ok) {
throw new Error(`Ntfy message could not be sent. Status code: ${res.status}`);
}
return res.text();
})
.catch((error) => {
// Ensure we reject with an Error object and prevent unhandled rejections
throw error instanceof Error ? error : new Error(String(error));
}); });
}); });