Add error handling for edit requests
This commit is contained in:
parent
d77d0d1c59
commit
5775ae0a8e
|
@ -73,7 +73,11 @@ export class MediaWikiClient {
|
|||
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,
|
||||
format: 'json',
|
||||
});
|
||||
// TODO: error handling
|
||||
return body;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue