Skip to content

fix: improve error handling for missing API data #10

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tonderflash
Copy link

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:

  • Replaced error throwing with logging when data is missing
  • Allow returning partial player data even when some sections are unavailable
  • Improved error messages to be more specific about what's missing

Changes

  • Modified RequestFullProfile in src/http/ubi-r6-stats.ts to handle missing data gracefully
  • Updated error messages in src/routes/r6/profiles.ts to be more descriptive
  • Added appropriate comments to explain the fallback behavior

Testing

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:

{"code":500,"error":"Internal Server Error","message":"Something went wrong on our end. Please contact our support team if this error persists."}

After:

{
  "code": 200,
  "profiles": {
    "b5c5f466-87ef-4b1d-bfe6-2d265ffbd14f": {
      "currentSeason": {
        "ranked": {
          "abandons": 0,
          "championNumber": 1,
          "deaths": 1364,
          "kdRatio": "1.64",
          "kills": 2235,
          "losses": 16,
          "maxRank": "champion",
          "maxRankPoints": 5967,
          "nextRank": "champion",
          "nextRankByMaxRank": "champion",
          "nextRankRankPoints": 5967,
          "previousRank": "diamond i",
          "rank": "champion",
          "rankPointProgress": 1,
          "rankPoints": 5967,
          "winPercent": "96.42%",
          "wins": 16
        }
      },
      "level": 619,
      "lifetime": null,
      "modified": 1744384588,
      "operators": null,
      "platform": "uplay",
      "profileId": "b5c5f466-87ef-4b1d-bfe6-2d265ffbd14f"
    }
  }
}


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