chore: Clean up some catch errors

This commit is contained in:
Edmund Miller 2022-11-13 17:02:40 -06:00 committed by Thomas A. Christensen II
parent a14c1ba3a6
commit 955a936296

View file

@ -20,11 +20,13 @@ async function run(): Promise<void> {
let octokit = {} let octokit = {}
try { try {
octokit = github.getOctokit(token) octokit = github.getOctokit(token)
} catch (e) { } catch (e: unknown) {
if (e instanceof Error) {
core.setFailed( core.setFailed(
`Could not authenticate to GitHub Releases API with provided token\n${e.message}` `Could not authenticate to GitHub Releases API with provided token\n${e.message}`
) )
} }
}
// Get the release info for the desired release // Get the release info for the desired release
let release = {} let release = {}
@ -32,20 +34,24 @@ async function run(): Promise<void> {
release = await release_data(version, octokit) release = await release_data(version, octokit)
resolved_version = release.tag_name resolved_version = release.tag_name
core.info(`Input version '${version}' resolved to Nextflow ${release.name}`) core.info(`Input version '${version}' resolved to Nextflow ${release.name}`)
} catch (e) { } catch (e: unknown) {
if (e instanceof Error) {
core.setFailed( core.setFailed(
`Could not retrieve Nextflow release matching ${version}.\n${e.message}` `Could not retrieve Nextflow release matching ${version}.\n${e.message}`
) )
} }
}
// Get the download url for the desired release // Get the download url for the desired release
let url = '' let url = ''
try { try {
url = nextflow_bin_url(release, get_all) url = nextflow_bin_url(release, get_all)
core.info(`Preparing to download from ${url}`) core.info(`Preparing to download from ${url}`)
} catch (e) { } catch (e: unknown) {
if (e instanceof Error) {
core.setFailed(`Could not parse the download URL\n${e.message}`) core.setFailed(`Could not parse the download URL\n${e.message}`)
} }
}
try { try {
// Download Nextflow and add it to path // Download Nextflow and add it to path
let nf_path = '' let nf_path = ''
@ -66,18 +72,22 @@ async function run(): Promise<void> {
core.addPath(nf_path) core.addPath(nf_path)
core.info(`Downloaded \`nextflow\` to ${nf_path} and added to PATH`) core.info(`Downloaded \`nextflow\` to ${nf_path} and added to PATH`)
} catch (e) { } catch (e: unknown) {
if (e instanceof Error) {
core.setFailed(e.message) core.setFailed(e.message)
} }
}
// Run Nextflow so it downloads its dependencies // Run Nextflow so it downloads its dependencies
try { try {
await exec.exec('nextflow', ['help']) await exec.exec('nextflow', ['help'])
} catch (e) { } catch (e: unknown) {
if (e instanceof Error) {
core.warning( core.warning(
'Nextflow appears to have installed correctly, but an error was thrown while running it.' 'Nextflow appears to have installed correctly, but an error was thrown while running it.'
) )
} }
} }
}
run() run()