Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve request handling & logging #82

Closed
wants to merge 1 commit into from

Conversation

samson10504
Copy link

📝 Summary

This PR improves the stability and maintainability of the codebase by enhancing request handling, removing unreachable code, and improving error logging.

🔄 Changes

  • Enhanced error handling:
    • Added try/catch blocks for all API requests.
    • Implemented status checks to ensure proper request handling.
  • Refactored unreachable code:
    • Removed redundant return statements in getDownloadStatsOrUpdate().
    • Eliminated undefined variables (electronJSON and nightlyJSON).
  • Implemented fallback values:
    • Ensured meaningful defaults when request failures occur.
  • Improved logging:
    • Added contextual details to error logs for easier debugging.

🛠️ Reason for Changes

🔍 Unreachable Code Removal

In getDownloadStatsOrUpdate(), the following code was redundant and caused issues:

const response = await fetch('https://electron-sudowoodo.herokuapp.com/release/active');
return response.json();
return {
  electron: electronJSON,
  nightly: nightlyJSON,
};
image

@samson10504 samson10504 requested review from a team as code owners March 7, 2025 19:19
- Added `try/catch` for API requests with status checks
- Removed unreachable code in `getDownloadStatsOrUpdate()`
- Eliminated undefined vars (`electronJSON`, `nightlyJSON`)
- Set fallback values for request failures
- Improved error logs with contextual details
@samson10504 samson10504 marked this pull request as draft March 7, 2025 19:46
@samson10504 samson10504 marked this pull request as ready for review March 7, 2025 19:48
@samson10504 samson10504 deleted the branch electron:main March 7, 2025 19:53
@samson10504 samson10504 closed this Mar 7, 2025
@samson10504 samson10504 deleted the main branch March 7, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant