Skip to content

Commit 9d82879

Browse files
Apply suggestions from cocdcdfde reviewf
cxc Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 49c4f3a commit 9d82879

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/api/train/train.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export const getTrainingGame = async () => {
5353
})
5454

5555
// Build game tree from moves
56+
if (moves.length === 0) {
57+
throw new Error("Moves array is empty. Cannot initialize GameTree.");
58+
}
5659
const gameTree = new GameTree(moves[0].board)
5760
let currentNode = gameTree.getRoot()
5861

src/api/turing/turing.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export const getTuringGame = async () => {
3838
)
3939

4040
// Build game tree from moves
41+
if (moves.length === 0) {
42+
throw new Error('No moves available to initialize the game tree');
43+
}
4144
const gameTree = new GameTree(moves[0].board)
4245
let currentNode = gameTree.getRoot()
4346

0 commit comments

Comments
 (0)