mirror of
https://github.com/actions/setup-java.git
synced 2026-05-03 23:59:11 +00:00
Refactor error handling and improve test logging for installers (#989)
* Refactor error handling for version not found cases across multiple installers * Mock core.error in tests to suppress error logs * fix(graalvm): improve error messages for EA version not found scenarios * refactor(tests): update error messages for version not found scenarios * fix(graalvm): enhance error messages for version not found scenarios * fix(graalvm): improve error messages for version not found scenarios with updated download URL * fix(graalvm): improve error handling for EA version not found scenarios with clearer messages
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
} from '../../util';
|
||||
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||
const GRAALVM_MIN_VERSION = 17;
|
||||
@@ -149,9 +150,10 @@ export class GraalVMDistribution extends JavaBase {
|
||||
const statusCode = response.message.statusCode;
|
||||
|
||||
if (statusCode === HttpCodes.NotFound) {
|
||||
throw new Error(
|
||||
`Could not find GraalVM for SemVer ${range}. Please check if this version is available at ${GRAALVM_DL_BASE}`
|
||||
);
|
||||
// Create the standard error with additional hint about checking the download URL
|
||||
const error = this.createVersionNotFoundError(range);
|
||||
error.message += `\nPlease check if this version is available at ${GRAALVM_DOWNLOAD_URL} . Pick a version from the list.`;
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -180,10 +182,12 @@ export class GraalVMDistribution extends JavaBase {
|
||||
|
||||
const latestVersion = versions.find(v => v.latest);
|
||||
if (!latestVersion) {
|
||||
core.error(
|
||||
`Available versions: ${versions.map(v => v.version).join(', ')}`
|
||||
const availableVersions = versions.map(v => v.version);
|
||||
throw this.createVersionNotFoundError(
|
||||
javaEaVersion,
|
||||
availableVersions,
|
||||
'Note: No EA build is marked as latest for this version.'
|
||||
);
|
||||
throw new Error(`Unable to find latest version for '${javaEaVersion}'`);
|
||||
}
|
||||
|
||||
core.debug(`Latest version found: ${latestVersion.version}`);
|
||||
|
||||
Reference in New Issue
Block a user