Skip to content

Commit

Permalink
Better error for 404
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed May 30, 2024
1 parent 68b7059 commit 12dfa2b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
16 changes: 13 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
if (found) {
version = found
} else {
throw new Error(`Unknown version ${parsedVersion} for ${engine} on ${platform}
available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}
throw new Error(`Unknown version ${parsedVersion} for ${engine} on ${platform}.
Available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}.
Make sure you use the latest version of the action with - uses: ruby/setup-ruby@v1`)
}
}
Expand Down
12 changes: 11 additions & 1 deletion ruby-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ async function downloadAndExtract(platform, engine, version, rubyPrefix) {
const downloadPath = await common.measure('Downloading Ruby', async () => {
const url = getDownloadURL(platform, engine, version)
console.log(url)
return await tc.downloadTool(url)
try {
return await tc.downloadTool(url)
} catch (error) {
if (error.message.endsWith('404')) {
throw new Error(`Unavailable version ${version} for ${engine} on ${platform}.
You can request it at https://github.com/ruby/setup-ruby/issues.
Original Error: (${error.message})`)
} else {
throw error
}
}
})

await common.measure('Extracting Ruby', async () => {
Expand Down

0 comments on commit 12dfa2b

Please sign in to comment.