Skip to content

Commit 9f85f34

Browse files
authored
Update generateIndex.js
1 parent 7084ca9 commit 9f85f34

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

generateIndex.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ let headers = {
88
async function getRepos(url) {
99
try {
1010
const response = await fetch(url, { headers });
11-
if (!response.ok) throw new Error("Failed to fetch repositories");
11+
if (!response.ok) {
12+
const errorDetails = await response.text(); // Capture response body for detailed error logging
13+
throw new Error(`Failed to fetch repositories ${url} - Status: ${response.status} - Response: ${errorDetails}`);
14+
}
1215
const repos = await response.json();
1316
return repos.map(repo => ({
1417
name: repo.name,
@@ -30,7 +33,10 @@ async function appendRepoContributers(repos) {
3033
if (repo.contributors_url) {
3134
try {
3235
const contributorsResponse = await fetch(repo.contributors_url);
33-
if (!contributorsResponse.ok) throw new Error("Failed to fetch contributors");
36+
if (!contributorsResponse.ok) {
37+
const errorDetails = await contributorsResponse.text();
38+
throw new Error(`Failed to fetch contributors for ${repo.name} - Status: ${contributorsResponse.status} - Response: ${errorDetails}`);
39+
}
3440
repo.contributorsList = (await contributorsResponse.json())
3541
.map(contributor => ({
3642
avatar_url: contributor.avatar_url,

0 commit comments

Comments
 (0)