From a2ad0bce555e972f281c9b1399db2fd2347069a1 Mon Sep 17 00:00:00 2001 From: llama <100429699+iamllama@users.noreply.github.com> Date: Sat, 14 Dec 2024 18:32:51 +0800 Subject: [PATCH] Fix CardInfoPlaceholder not showing when card id is invalid (#3631) * Catch bigint parsing error * Modify CONTRIBUTORS --- ts/routes/card-info/[cardId]/+page.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ts/routes/card-info/[cardId]/+page.ts b/ts/routes/card-info/[cardId]/+page.ts index 35b0dd9a8..33c3304a6 100644 --- a/ts/routes/card-info/[cardId]/+page.ts +++ b/ts/routes/card-info/[cardId]/+page.ts @@ -4,7 +4,16 @@ import { cardStats } from "@generated/backend"; import type { PageLoad } from "./$types"; +function optionalBigInt(x: any): bigint | null { + try { + return BigInt(x); + } catch (e) { + return null; + } +} + export const load = (async ({ params }) => { - const info = await cardStats({ cid: BigInt(params.cardId) }); + const cid = optionalBigInt(params.cardId); + const info = cid !== null ? await cardStats({ cid }) : null; return { info }; }) satisfies PageLoad;