Skip to content

Commit 7d189e2

Browse files
committed
Improve error message when a version is not available
1 parent 77cddd7 commit 7d189e2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

dist/index.js

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

index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,19 @@ async function getRubyEngineAndVersion(rubyVersion) {
5252
const stableVersions = response.data
5353
const engineVersions = stableVersions[engine]
5454
if (!engineVersions) {
55-
throw new Error(`Unknown engine ${engine} (${rubyVersion})`)
55+
throw new Error(`Unknown engine ${engine} (input: ${rubyVersion})`)
5656
}
5757

5858
if (!engineVersions.includes(version)) {
59-
engineVersions.reverse() // inplace!
60-
let found = engineVersions.find(v => v.startsWith(version))
59+
const latestToFirstVersion = engineVersions.slice().reverse()
60+
const found = latestToFirstVersion.find(v => v.startsWith(version))
6161
if (found) {
6262
version = found
6363
} else {
64-
throw new Error(`Unknown version ${version} (${rubyVersion})`)
64+
throw new Error(`Unknown version ${version} for ${engine}
65+
input: ${rubyVersion}
66+
available versions for ${engine}: ${engineVersions.join(', ')}
67+
File an issue at https://github.com/eregon/ruby-install-builder/issues if would like support for a new version`)
6568
}
6669
}
6770

0 commit comments

Comments
 (0)