Skip to content

Commit

Permalink
Merge pull request #61 from VisActor/chore/bugserver-ci
Browse files Browse the repository at this point in the history
chore: add log in bugserver github-ci
  • Loading branch information
xile611 authored Jul 18, 2023
2 parents 2aea7d6 + 630e2b2 commit 7205dc3
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions packages/vgrammar/github-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,28 @@ const fetch = async (url, options) => {
...commonHeader
}
}
const result = await nodeFetch(url, newOptions);
const json = await result.json();
if(json.code === -1) {
console.log(`request url: ${url}`)
throw new Error(`Request Fail, msg: ${json.msg}`)
let data = null;
try {
const response = await nodeFetch(url, newOptions);

console.info("[fetch][response.url]", response.url);
console.info("[fetch][response.status]", response.status);
console.info("[fetch][response.headers]", JSON.stringify(response.headers.raw()));

data = await response.json();

if (data.code === -1) {
throw new Error(`Request failed with data: ${JSON.stringify(data)}`);
}
} catch (err) {
console.error("[fetch][err]", err);
}
return json;

if (data === null) {
throw new Error(`[fetch][failed] response data not exists`);
}

return data;
}

const getFormData = (data) => {
Expand Down

0 comments on commit 7205dc3

Please sign in to comment.