fix: improve error handling for missing API data #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improved Error Handling for Missing API Data
Problem
The API was failing with 500 Internal Server Error when player data was incomplete or missing specific sections (operators, lifetime stats, etc.). This happened with valid players like NC4L.SSG, who had profiles on R6 Tracker but couldn't be accessed through this API.
Solution
Modified the error handling approach to be more graceful:
Changes
RequestFullProfile
insrc/http/ubi-r6-stats.ts
to handle missing data gracefullysrc/routes/r6/profiles.ts
to be more descriptiveTesting
Tested with the player "NC4L.SSG" who previously returned a 500 error. After this fix, the API successfully returns the available player data including rank, level, and current season stats, while marking missing sections as
null
.Screenshots
Before:
After: