From 0e7574b10ede783d78d4c0cd982a8ad8bccf912c Mon Sep 17 00:00:00 2001 From: Mido Date: Wed, 16 Oct 2024 04:28:00 +0900 Subject: [PATCH] show number when katanuki produced errors --- apps/frontend/src/app/routes/replay.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/frontend/src/app/routes/replay.tsx b/apps/frontend/src/app/routes/replay.tsx index 6f8169a..60bab69 100644 --- a/apps/frontend/src/app/routes/replay.tsx +++ b/apps/frontend/src/app/routes/replay.tsx @@ -31,12 +31,22 @@ export default function Page() { const boards: string[][] = [structuredClone(replayInfo.problem.board.start)]; - for (const op of replayInfo.answer.ops) { - const afterBoard = easyKatanuki(replayInfo.problem, op); + for (const [i, op] of replayInfo.answer.ops.entries()) { + try { + const afterBoard = easyKatanuki(replayInfo.problem, op); - replayInfo.problem.board.start = afterBoard; + replayInfo.problem.board.start = afterBoard; - boards.push(afterBoard); + boards.push(afterBoard); + } catch (e) { + if (e instanceof Error) { + throw new Error(`Failed to apply operation ${i + 1}`, { cause: e }); + } + + console.error(e); + + throw new Error(`Failed to apply operation ${i + 1}`); + } } replayInfo.problem.board.start = boards[0];