1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-09-16 09:41:38 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Print server error

This commit is contained in:
sunnylqm
2021-06-23 10:05:29 +08:00
parent 11799dd0c1
commit a7b79a30e8

View File

@@ -65,7 +65,14 @@ exports.closeSession = function () {
async function query(url, options) {
const resp = await fetch(url, options);
const json = await resp.json();
const text = await resp.text();
let json;
try {
json = JSON.parse(text);
} catch (e) {
throw new Error(`Server error: ${text}`);
}
if (resp.status !== 200) {
throw Object.assign(new Error(json.message || json.error), {
status: resp.status,