build(dev-infra): handle async failures in `get-data.ts` (#36007)

Wrap the await block in a try/catch so not to have unhandled promise rejections.

PR Close #36007
This commit is contained in:
Alan Agius 2020-03-11 09:01:44 +01:00 committed by Matias Niemelä
parent 5f7d06668e
commit 77da6887f7
1 changed files with 11 additions and 5 deletions

View File

@ -232,12 +232,18 @@ function buildQueryAndParams(username: string, date: string) {
* of the organization. * of the organization.
*/ */
async function run(date: string) { async function run(date: string) {
console.info(['Username'].concat(buildQueryAndParams('', date).labels).join(',')); try {
const allOrgMembers = await getAllOrgMembers();
console.info(['Username', ...buildQueryAndParams('', date).labels].join(','));
for (let username of await getAllOrgMembers()) { for (const username of allOrgMembers) {
const results = await graphql(buildQueryAndParams(username, date).query); const results = await graphql(buildQueryAndParams(username, date).query);
const values = Object.values(results).map(result => `${result.issueCount}`); const values = Object.values(results).map(result => `${result.issueCount}`);
console.info([username].concat(values).join(',')); console.info([username, ...values].join(','));
}
} catch (error) {
console.error(`Error: ${error.message}`);
process.exit(1);
} }
} }