Add error handling for edit requests

This commit is contained in:
ewin 2025-04-03 07:39:59 -04:00
parent d77d0d1c59
commit 5775ae0a8e
Signed by: erin
SSH key fingerprint: SHA256:swjoHhREbZPbWe+gyJNi24d4NAxJSyUIm3fpZj4z3wc

View file

@ -73,7 +73,11 @@ export class MediaWikiClient {
format: 'json', format: 'json',
}), }),
}); });
return response.json(); const body = await response.json();
if (body.error) {
throw new Error(`[${body.error.code}] ${body.error.info}`);
}
return body;
} }
/** /**
@ -155,7 +159,6 @@ export class MediaWikiClient {
token: csrfToken, token: csrfToken,
format: 'json', format: 'json',
}); });
// TODO: error handling
return body; return body;
} }