From fb3b65568f5a7d366ab85803307ed4fad335862c Mon Sep 17 00:00:00 2001 From: Aparna Jyothi Date: Mon, 3 Feb 2025 17:04:56 +0530 Subject: [PATCH] error --- dist/setup/index.js | 21 +++++++++++++++++++-- src/distributions/base-distribution.ts | 15 ++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 56434c07..3d9e7750 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -100158,8 +100158,25 @@ class BaseDistribution { return __awaiter(this, void 0, void 0, function* () { const initialUrl = this.getDistributionUrl(); const dataUrl = `${initialUrl}/index.json`; - const response = yield this.httpClient.getJson(dataUrl); - return response.result || []; + try { + const response = yield this.httpClient.getJson(dataUrl); + return response.result || []; + } + catch (err) { + if (err instanceof Error && err.message.includes('getaddrinfo EAI_AGAIN')) { + core.error(`Network error: Failed to resolve the server at ${dataUrl}. + Please check your DNS settings or verify that the URL is correct.`); + } + else if (err instanceof hc.HttpClientError && err.statusCode === 404) { + core.error(`404 Error: Unable to find versions at ${dataUrl}. + Please verify that the mirror URL is valid.`); + } + else { + core.error(`Failed to fetch Node.js versions from ${dataUrl}. + Please check the URL and try again.}`); + } + throw err; + } }); } getNodejsDistInfo(version) { diff --git a/src/distributions/base-distribution.ts b/src/distributions/base-distribution.ts index fcebaffc..29243798 100644 --- a/src/distributions/base-distribution.ts +++ b/src/distributions/base-distribution.ts @@ -108,9 +108,22 @@ export default abstract class BaseDistribution { const initialUrl = this.getDistributionUrl(); const dataUrl = `${initialUrl}/index.json`; - + try { const response = await this.httpClient.getJson(dataUrl); return response.result || []; + }catch (err) { + if (err instanceof Error && err.message.includes('getaddrinfo EAI_AGAIN')) { + core.error(`Network error: Failed to resolve the server at ${dataUrl}. + Please check your DNS settings or verify that the URL is correct.`); + } else if (err instanceof hc.HttpClientError && err.statusCode === 404) { + core.error(`404 Error: Unable to find versions at ${dataUrl}. + Please verify that the mirror URL is valid.`); + } else { + core.error(`Failed to fetch Node.js versions from ${dataUrl}. + Please check the URL and try again.}`); + } + throw err; + } } protected getNodejsDistInfo(version: string) {