Skip to content

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