diff --git a/dist/setup/index.js b/dist/setup/index.js index 7939076e..391e4d6a 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -128801,36 +128801,26 @@ class JavaBase { } else { core.info('Trying to download...'); - try { - foundJava = yield this.downloadTool(javaRelease); - core.info(`Java ${foundJava.version} was downloaded`); - } - catch (downloadError) { - core.error('Failed to download Java. Please check your network connection or the provided version.'); - core.error(`Error details: ${downloadError.message}`); - throw downloadError; - } + foundJava = yield this.downloadTool(javaRelease); + core.info(`Java ${foundJava.version} was downloaded`); } } - catch (resolveError) { - if (resolveError instanceof tc.HTTPError && - resolveError.httpStatusCode === 403) { + catch (error) { + if (error instanceof tc.HTTPError && error.httpStatusCode === 403) { core.error(`Received HTTP 403: Permission denied or restricted access.`); } - else if (resolveError instanceof tc.HTTPError && - resolveError.httpStatusCode === 429) { + else if (error instanceof tc.HTTPError && + error.httpStatusCode === 429) { core.warning(`Received HTTP 429: Rate limit exceeded. Try again later.`); } else { - const message = resolveError instanceof Error - ? resolveError.message - : JSON.stringify(resolveError); + const message = error instanceof Error ? error.message : JSON.stringify(error); core.error(`Failed to set up Java due to a network issue or timeout: ${message}`); } - if (resolveError instanceof Error && resolveError.stack) { - core.debug(resolveError.stack); + if (error instanceof Error && error.stack) { + core.debug(error.stack); } - throw resolveError; + throw error; } } // JDK folder may contain postfix "Contents/Home" on macOS diff --git a/src/distributions/base-installer.ts b/src/distributions/base-installer.ts index 7610884f..4385c9bc 100644 --- a/src/distributions/base-installer.ts +++ b/src/distributions/base-installer.ts @@ -58,46 +58,33 @@ export abstract class JavaBase { core.info(`Resolved Java ${foundJava.version} from tool-cache`); } else { core.info('Trying to download...'); - try { - foundJava = await this.downloadTool(javaRelease); - core.info(`Java ${foundJava.version} was downloaded`); - } catch (downloadError: any) { - core.error( - 'Failed to download Java. Please check your network connection or the provided version.' - ); - core.error(`Error details: ${downloadError.message}`); - throw downloadError; - } + foundJava = await this.downloadTool(javaRelease); + core.info(`Java ${foundJava.version} was downloaded`); } - } catch (resolveError: any) { - if ( - resolveError instanceof tc.HTTPError && - resolveError.httpStatusCode === 403 - ) { + } catch (error: any) { + if (error instanceof tc.HTTPError && error.httpStatusCode === 403) { core.error( `Received HTTP 403: Permission denied or restricted access.` ); } else if ( - resolveError instanceof tc.HTTPError && - resolveError.httpStatusCode === 429 + error instanceof tc.HTTPError && + error.httpStatusCode === 429 ) { core.warning( `Received HTTP 429: Rate limit exceeded. Try again later.` ); } else { const message = - resolveError instanceof Error - ? resolveError.message - : JSON.stringify(resolveError); + error instanceof Error ? error.message : JSON.stringify(error); core.error( `Failed to set up Java due to a network issue or timeout: ${message}` ); } - if (resolveError instanceof Error && resolveError.stack) { - core.debug(resolveError.stack); + if (error instanceof Error && error.stack) { + core.debug(error.stack); } - throw resolveError; + throw error; } }