From 12dfa2bb470be612a06b153aaf7bd8d7c56deb1f Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Thu, 30 May 2024 15:01:16 +0200 Subject: [PATCH] Better error for 404 --- dist/index.js | 16 +++++++++++++--- index.js | 4 ++-- ruby-builder.js | 12 +++++++++++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index 511a1a59e..8923b3e5d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -65026,7 +65026,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 () => { @@ -65889,8 +65899,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`) } } diff --git a/index.js b/index.js index 4e8c1fec8..54106140e 100644 --- a/index.js +++ b/index.js @@ -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`) } } diff --git a/ruby-builder.js b/ruby-builder.js index 72e2cfc59..94ab9886a 100644 --- a/ruby-builder.js +++ b/ruby-builder.js @@ -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 () => {