refactor: protect against null, remove nullish coalescing

This commit is contained in:
Miodec 2025-04-26 18:56:58 +02:00
parent f60dd0ac3c
commit a59f99a533

View file

@ -221,17 +221,14 @@ export class WeeklyXpLeaderboard {
[null, string | null]
];
if (rank === null) {
if (rank === null || result === null) {
return null;
}
// safely parse the result with error handling
let parsed: RedisXpLeaderboardEntry;
try {
parsed = parseJsonWithSchema(
result ?? "null",
RedisXpLeaderboardEntrySchema
);
parsed = parseJsonWithSchema(result, RedisXpLeaderboardEntrySchema);
} catch (error) {
throw new MonkeyError(
500,