diff --git a/bin/can-merge b/bin/can-merge index 0079282..e29fb89 100755 --- a/bin/can-merge +++ b/bin/can-merge @@ -163,11 +163,11 @@ https.request(options, (response) => { watch(args.retryDelay, () => runQuery(params)).then((res) => { console.clear(); outputStatus(res); - }); + }).catch((error) => { console.log(chalk.red(error)); }); } else { runQuery(params).then((res) => { outputStatus(res); - }); + }).catch((error) => { console.log(chalk.red(error)); }); } }).on('error', (err) => { console.error(err); diff --git a/utils/runQuery.js b/utils/runQuery.js index 53a1499..f87fc26 100644 --- a/utils/runQuery.js +++ b/utils/runQuery.js @@ -1,15 +1,19 @@ 'use strict'; const { graphql } = require('@octokit/graphql'); - const buildQuery = require('./buildQuery'); module.exports = async function runQuery({ repo, pr, sha, token }) { const [owner, name] = repo.split('/'); - const response = await graphql(buildQuery({ name, owner, pr, sha }), { - headers: { - authorization: `token ${token}`, - }, - }); + let response = null; + try { + response = await graphql(buildQuery({ name, owner, pr, sha }), { + headers: { + authorization: `token ${token}`, + }, + }); + } catch (err) { + throw err.message; + } return response; };