Skip to content

Commit 12dfa2b

Browse files
committed
Better error for 404
1 parent 68b7059 commit 12dfa2b

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

dist/index.js

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

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
164164
if (found) {
165165
version = found
166166
} else {
167-
throw new Error(`Unknown version ${parsedVersion} for ${engine} on ${platform}
168-
available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}
167+
throw new Error(`Unknown version ${parsedVersion} for ${engine} on ${platform}.
168+
Available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}.
169169
Make sure you use the latest version of the action with - uses: ruby/setup-ruby@v1`)
170170
}
171171
}

ruby-builder.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ async function downloadAndExtract(platform, engine, version, rubyPrefix) {
6969
const downloadPath = await common.measure('Downloading Ruby', async () => {
7070
const url = getDownloadURL(platform, engine, version)
7171
console.log(url)
72-
return await tc.downloadTool(url)
72+
try {
73+
return await tc.downloadTool(url)
74+
} catch (error) {
75+
if (error.message.endsWith('404')) {
76+
throw new Error(`Unavailable version ${version} for ${engine} on ${platform}.
77+
You can request it at https://github.com/ruby/setup-ruby/issues.
78+
Original Error: (${error.message})`)
79+
} else {
80+
throw error
81+
}
82+
}
7383
})
7484

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

0 commit comments

Comments
 (0)