From e13d5c5faaf7ea7bc8f00c4fd4701e9e2f0c7514 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Mon, 15 Apr 2024 21:27:17 +0100 Subject: [PATCH] make errors getting issues non-fatal This can happen if someone moves a repo between the previous merge and then a release. The Issue number is the only thing that is used to get issue details but really the full path should be used (if at all possible). This change just prevents this situation from causing an unrecoverable error --- src/changelog.ts | 8 ++++++-- src/github-api.ts | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/changelog.ts b/src/changelog.ts index a540d85..e398ddc 100644 --- a/src/changelog.ts +++ b/src/changelog.ts @@ -178,8 +178,12 @@ export default class Changelog { await pMap( commitInfos, async (commitInfo: CommitInfo) => { - if (commitInfo.issueNumber) { - commitInfo.githubIssue = await this.github.getIssueData(this.config.repo, commitInfo.issueNumber); + try { + if (commitInfo.issueNumber) { + commitInfo.githubIssue = await this.github.getIssueData(this.config.repo, commitInfo.issueNumber); + } + } catch (err: any) { + console.error(`Error getting issue data: ${err.message}`); } progressBar.tick(); diff --git a/src/github-api.ts b/src/github-api.ts index 97429d5..31df497 100644 --- a/src/github-api.ts +++ b/src/github-api.ts @@ -68,7 +68,12 @@ export default class GithubAPI { if (res.ok) { return parsedResponse; } - throw new ConfigurationError(`Fetch error: ${res.statusText}.\n${JSON.stringify(parsedResponse)}`); + + if (res.status === 404) { + throw new ConfigurationError(`Not Found [${url}]`); + } + + throw new ConfigurationError(`Fetch error [${url}]: ${res.statusText}.\n${JSON.stringify(parsedResponse)}`); } private getAuthToken(): string {