Skip to content

Commit ec7ed74

Browse files
committed
catch go "panics" in startmatch
1 parent 24b7e31 commit ec7ed74

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

frontend/src/pages/Home.svelte

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
BotInfo,
88
ExtraOptions,
99
PlayerJs,
10+
Result,
1011
type StartMatchOptions,
1112
} from "../../bindings/gui/index.js";
1213
import arenaImages from "../arena-images";
@@ -318,7 +319,8 @@ async function onMatchStart(randomizeMap: boolean) {
318319
];
319320
}
320321
321-
function playerMap(draggable: DraggablePlayer): PlayerJs {
322+
// this syntax makes more sense when inside of another function
323+
const playerMap = (draggable: DraggablePlayer): PlayerJs => {
322324
let clone = { ...draggable };
323325
if (clone.player instanceof BotInfo) {
324326
clone.player = BotInfo.createFrom(structuredClone(clone.player));
@@ -352,7 +354,16 @@ async function onMatchStart(randomizeMap: boolean) {
352354
});
353355
startMatchToastId = toastId;
354356
355-
const response = await App.StartMatch(options);
357+
let response;
358+
try {
359+
response = await App.StartMatch(options);
360+
} catch(e) {
361+
toast.error(`Match start failed\n${e}`, {
362+
id: toastId,
363+
duration: 10000,
364+
});
365+
return;
366+
}
356367
357368
if (toastId !== startMatchToastId) return;
358369
startMatchToastId = null;

0 commit comments

Comments
 (0)