Skip to content

Commit d9e0f98

Browse files
authored
Improve error messages on GitHub API errors (#518)
Fixes: #513
1 parent e5d42a2 commit d9e0f98

File tree

4 files changed

+50
-14
lines changed

4 files changed

+50
-14
lines changed

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["biomejs.biome"]
3+
}

.vscode/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.action.useSortedAttributes.biome": "explicit",
4+
"source.action.useSortedKeys.biome": "explicit",
5+
"source.fixAll.biome": "explicit"
6+
},
7+
"editor.defaultFormatter": "biomejs.biome",
8+
"editor.formatOnSave": true,
9+
"explorer.excludeGitIgnore": false,
10+
"search.defaultViewMode": "list",
11+
"search.exclude": {
12+
"**/node_modules": true
13+
},
14+
"typescript.enablePromptUseWorkspaceTsdk": true,
15+
"typescript.tsdk": "node_modules/typescript/lib"
16+
}

dist/setup/index.js

Lines changed: 13 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/download/download-version.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ async function getReleaseTagNames(
184184
owner: OWNER,
185185
repo: REPO,
186186
});
187-
return response.map((release) => release.tag_name);
187+
const releaseTagNames = response.map((release) => release.tag_name);
188+
if (releaseTagNames.length === 0) {
189+
throw Error(
190+
"Github API request failed while getting releases. Check the GitHub status page for outages. Try again later.",
191+
);
192+
}
193+
return releaseTagNames;
188194
}
189195

190196
async function getLatestVersion(githubToken: string) {
@@ -197,14 +203,18 @@ async function getLatestVersion(githubToken: string) {
197203
try {
198204
latestRelease = await getLatestRelease(octokit);
199205
} catch (err) {
200-
core.info(
201-
"No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.",
202-
);
203-
if (err instanceof Error) {
204-
core.debug(err.message);
206+
if ((err as Error).message.includes("Bad credentials")) {
207+
core.info(
208+
"No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.",
209+
);
210+
const octokit = new Octokit();
211+
latestRelease = await getLatestRelease(octokit);
212+
} else {
213+
core.error(
214+
"Github API request failed while getting latest release. Check the GitHub status page for outages. Try again later.",
215+
);
216+
throw err;
205217
}
206-
const octokit = new Octokit();
207-
latestRelease = await getLatestRelease(octokit);
208218
}
209219

210220
if (!latestRelease) {

0 commit comments

Comments
 (0)