Skip to content

Commit

Permalink
Errors resulting from the GitHub API calls should now be properly rai…
Browse files Browse the repository at this point in the history
…sed (#820)

* Errors resulting from the GitHub API calls should now be properly raised

* Update packages/get-github-info/src/index.ts

Co-authored-by: Mitchell Hamilton <mitchell@hamil.town>
  • Loading branch information
Andarist and emmatown committed May 31, 2022
1 parent c54c25d commit a22eb8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/tough-rats-sip.md
@@ -0,0 +1,6 @@
---
"@changesets/get-github-info": patch
"@changesets/changelog-github": patch
---

Errors resulting from the GitHub API calls should now be properly raised.
12 changes: 11 additions & 1 deletion packages/get-github-info/src/index.ts
Expand Up @@ -58,7 +58,7 @@ function makeQuery(repos: ReposWithCommitsAndPRsToFetch) {
mergeCommit {
commitUrl
abbreviatedOid
}
}
}`
)
.join("\n")}
Expand Down Expand Up @@ -100,6 +100,16 @@ const GHDataLoader = new DataLoader(async (requests: RequestData[]) => {
body: JSON.stringify({ query: makeQuery(repos) })
}).then((x: any) => x.json());

if (data.errors) {
throw new Error(
`An error occurred when fetching data from GitHub\n${JSON.stringify(
data.errors,
null,
2
)}`
);
}

// this is mainly for the case where there's an authentication problem
if (!data.data) {
throw new Error(
Expand Down

0 comments on commit a22eb8c

Please sign in to comment.