豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 8d84592

Browse files
committed
fix(ng-dev): properly catch github API errors and print clean output (#877)
Currently when e.g. GitHub API merge fails with a 405 error, the whole output is printed. This is super spammy and the actual GitHub error message is not easy to spot. This fixes it by also catching non-403 GitHub API errors and printing them. PR Close #877
1 parent 8a9577a commit 8d84592

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ng-dev/pr/merge/merge-pull-request.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ export async function mergePullRequest(prNumber: number, flags: PullRequestMerge
5656
// Catch errors to the Github API for invalid requests. We want to
5757
// exit the script with a better explanation of the error.
5858
if (e instanceof GithubApiRequestError && e.status === 401) {
59-
Log.error('Github API request failed. ' + e.message);
59+
Log.error('Github API request failed: ' + bold(e.message));
6060
Log.error('Please ensure that your provided token is valid.');
6161
Log.warn(`You can generate a token here: ${GITHUB_TOKEN_GENERATE_URL}`);
6262
return false;
6363
}
64+
if (e instanceof GithubApiRequestError) {
65+
Log.error('Github API request failed: ' + bold(e.message));
66+
return false;
67+
}
6468
if (e instanceof UserAbortedMergeToolError) {
6569
Log.warn('Manually aborted merging..');
6670
return false;

ng-dev/pr/merge/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ export function getTargetedBranchesMessage(pullRequest: PullRequest): string {
2424
const targetBranchListAsString = pullRequest.targetBranches
2525
.map((b) => ` - ${bold(b)}`)
2626
.join('\n');
27-
return `Pull request #${pullRequest.prNumber} will merge into:\n${targetBranchListAsString}`;
27+
return `Pull Request #${pullRequest.prNumber} will merge into:\n${targetBranchListAsString}`;
2828
}

0 commit comments

Comments
 (0)