Add error handling for edit requests
This commit is contained in:
parent
d77d0d1c59
commit
5775ae0a8e
1 changed files with 5 additions and 2 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue