Improve error messages

This improves error messages throughout. It might sometimes be too verbose, but that's better than being opaque (#74).

Also upgrades Deno's patch version.

Fixes #74
This commit is contained in:
Bruno Bernardino
2025-06-23 08:57:02 +01:00
parent cb95085ea3
commit e0ad428a9f
16 changed files with 188 additions and 13 deletions

View File

@@ -33,10 +33,15 @@ export default function Links({ initialLinks }: LinksProps) {
method: 'POST',
body: JSON.stringify(requestBody),
});
if (!response.ok) {
throw new Error(`Failed to save link. ${response.statusText} ${await response.text()}`);
}
const result = await response.json() as ResponseBody;
if (!result.success) {
throw new Error('Failed to save notes!');
throw new Error('Failed to save link!');
}
} catch (error) {
console.error(error);

View File

@@ -28,6 +28,11 @@ export default function Notes({ initialNotes }: NotesProps) {
method: 'POST',
body: JSON.stringify(requestBody),
});
if (!response.ok) {
throw new Error(`Failed to save notes. ${response.statusText} ${await response.text()}`);
}
const result = await response.json() as ResponseBody;
if (!result.success) {