update error message and improved code

This commit is contained in:
mahabaleshwars 2025-04-09 15:12:48 +05:30
parent 6e5e551441
commit c1df1459aa
2 changed files with 21 additions and 20 deletions

15
dist/setup/index.js vendored
View file

@ -97481,18 +97481,16 @@ function getManifest() {
repoManifest.every(isIToolRelease)) { repoManifest.every(isIToolRelease)) {
return repoManifest; return repoManifest;
} }
else {
throw new Error('The repository manifest is invalid or does not include any valid tool release (IToolRelease) entries.'); throw new Error('The repository manifest is invalid or does not include any valid tool release (IToolRelease) entries.');
} }
}
catch (err) { catch (err) {
core.error('Fetching the manifest via the API failed.'); core.error('Failed to fetch the manifest from the repository API.');
if (err instanceof Error) { if (err instanceof Error) {
core.debug(`Error message: ${err.message}`); core.error(`Error message: ${err.message}`);
core.debug(`Error stack: ${err.stack}`); core.debug(`Error stack: ${err.stack}`);
} }
else { else {
core.error('Error is not an instance of Error. It might be something else.'); core.error('An unexpected error occurred while fetching the manifest.');
} }
} }
return yield getManifestFromURL(); return yield getManifestFromURL();
@ -97564,8 +97562,11 @@ function installCpythonFromRelease(release) {
catch (err) { catch (err) {
if (err instanceof tc.HTTPError) { if (err instanceof tc.HTTPError) {
// Rate limit? // Rate limit?
if (err.httpStatusCode === 403 || err.httpStatusCode === 429) { if (err.httpStatusCode === 403) {
core.error(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`); core.error(`Received HTTP status code 403 (Forbidden). This usually indicates that the request is not authorized. Please check your credentials or permissions.`);
}
else if (err.httpStatusCode === 429) {
core.error(`Received HTTP status code 429 (Too Many Requests). This usually indicates that the rate limit has been exceeded. Please wait and try again later.`);
} }
else { else {
core.error(err.message); core.error(err.message);

View file

@ -53,27 +53,23 @@ function isIToolRelease(obj: any): obj is IToolRelease {
export async function getManifest(): Promise<tc.IToolRelease[]> { export async function getManifest(): Promise<tc.IToolRelease[]> {
try { try {
const repoManifest = await getManifestFromRepo(); const repoManifest = await getManifestFromRepo();
if ( if (
Array.isArray(repoManifest) && Array.isArray(repoManifest) &&
repoManifest.length && repoManifest.length &&
repoManifest.every(isIToolRelease) repoManifest.every(isIToolRelease)
) { ) {
return repoManifest; return repoManifest;
} else { }
throw new Error( throw new Error(
'The repository manifest is invalid or does not include any valid tool release (IToolRelease) entries.' 'The repository manifest is invalid or does not include any valid tool release (IToolRelease) entries.'
); );
}
} catch (err) { } catch (err) {
core.error('Fetching the manifest via the API failed.'); core.error('Failed to fetch the manifest from the repository API.');
if (err instanceof Error) { if (err instanceof Error) {
core.debug(`Error message: ${err.message}`); core.error(`Error message: ${err.message}`);
core.debug(`Error stack: ${err.stack}`); core.debug(`Error stack: ${err.stack}`);
} else { } else {
core.error( core.error('An unexpected error occurred while fetching the manifest.');
'Error is not an instance of Error. It might be something else.'
);
} }
} }
return await getManifestFromURL(); return await getManifestFromURL();
@ -153,9 +149,13 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) {
} catch (err) { } catch (err) {
if (err instanceof tc.HTTPError) { if (err instanceof tc.HTTPError) {
// Rate limit? // Rate limit?
if (err.httpStatusCode === 403 || err.httpStatusCode === 429) { if (err.httpStatusCode === 403) {
core.error( core.error(
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded` `Received HTTP status code 403 (Forbidden). This usually indicates that the request is not authorized. Please check your credentials or permissions.`
);
} else if (err.httpStatusCode === 429) {
core.error(
`Received HTTP status code 429 (Too Many Requests). This usually indicates that the rate limit has been exceeded. Please wait and try again later.`
); );
} else { } else {
core.error(err.message); core.error(err.message);