Skip to content

Commit a25c57c

Browse files
committed
Wrap API call to provide better error message
1 parent 48017e9 commit a25c57c

File tree

6 files changed

+105
-71
lines changed

6 files changed

+105
-71
lines changed

lib/analyze-action.js

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

lib/init-action-post.js

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

lib/init-action.js

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

lib/upload-lib.js

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

lib/upload-sarif-action.js

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

src/setup-codeql.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -799,21 +799,25 @@ async function getNightlyToolsUrl(logger: Logger) {
799799
? "zstd"
800800
: "gzip";
801801

802-
// Since nightlies are prereleases, we can't just download the latest release
803-
// on the repository. So instead we need to find the latest pre-release
804-
// version and construct the download URL from that.
805-
const release = await api.getApiClient().rest.repos.listReleases({
806-
owner: CODEQL_NIGHTLIES_REPOSITORY_OWNER,
807-
repo: CODEQL_NIGHTLIES_REPOSITORY_NAME,
808-
per_page: 1,
809-
page: 1,
810-
prerelease: true,
811-
});
812-
813-
const latestRelease = release.data[0];
814-
if (!latestRelease) {
815-
throw new Error("Could not find latest nightly release.");
802+
try {
803+
// Since nightlies are prereleases, we can't just download the latest release
804+
// on the repository. So instead we need to find the latest pre-release
805+
// version and construct the download URL from that.
806+
const release = await api.getApiClient().rest.repos.listReleases({
807+
owner: CODEQL_NIGHTLIES_REPOSITORY_OWNER,
808+
repo: CODEQL_NIGHTLIES_REPOSITORY_NAME,
809+
per_page: 1,
810+
page: 1,
811+
prerelease: true,
812+
});
813+
const latestRelease = release.data[0];
814+
if (!latestRelease) {
815+
throw new Error("Could not find the latest nightly release.");
816+
}
817+
return `https://github.com/${CODEQL_NIGHTLIES_REPOSITORY_OWNER}/${CODEQL_NIGHTLIES_REPOSITORY_NAME}/releases/download/${latestRelease.tag_name}/${getCodeQLBundleName(compressionMethod)}`;
818+
} catch (e) {
819+
throw new Error(
820+
`Failed to retrieve the latest nightly release: ${util.wrapError(e)}`,
821+
);
816822
}
817-
818-
return `https://github.com/${CODEQL_NIGHTLIES_REPOSITORY_OWNER}/${CODEQL_NIGHTLIES_REPOSITORY_NAME}/releases/download/${latestRelease.tag_name}/${getCodeQLBundleName(compressionMethod)}`;
819823
}

0 commit comments

Comments
 (0)