-
Notifications
You must be signed in to change notification settings - Fork 81
Missing Error Handling for API Calls #179
Copy link
Copy link
Open
Description
Summary:
The code fetches data from the GitHub API but does not handle scenarios where the request fails (e.g., 404 Not Found, 403 Rate Limited, or 500 Server Error). This causes the application to attempt to read properties like result.full_name from an error response or undefined object, leading to runtime crashes.
Fix:
Implement try-catch blocks and check the response.ok status before processing data.
Corrected Code Snippet (Logic for loadActiveRepoDetails.js):
try {
const response = await fetch(repo_endpoint, { /* headers */ });
if (!response.ok) {
console.error(`Error fetching ${repo_name}: ${response.statusText}`);
return null;
}
const result = await response.json();
// ... processing
} catch (error) {
console.error("Network or parsing error:", error);
return null;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels