mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-04 12:34:53 +08:00
refactor: protect against null, remove nullish coalescing
This commit is contained in:
parent
f60dd0ac3c
commit
a59f99a533
1 changed files with 2 additions and 5 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue