Skip to content

Commit be794ac

Browse files
committed
chore: catch errors thrown when fetching release from github
1 parent fee0b74 commit be794ac

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

frontend/src/ts/states/version.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { z } from "zod";
22
import { getLatestReleaseFromGitHub } from "../utils/json-data";
33
import { LocalStorageWithSchema } from "../utils/local-storage-with-schema";
4+
import { tryCatch } from "@monkeytype/util/trycatch";
5+
import { createErrorMessage } from "../utils/misc";
46

57
const memoryLS = new LocalStorageWithSchema({
68
key: "lastSeenVersion",
@@ -20,7 +22,19 @@ function getMemory(): string {
2022
}
2123

2224
async function check(): Promise<void> {
23-
const currentVersion = await getLatestReleaseFromGitHub();
25+
const { data: currentVersion, error } = await tryCatch(
26+
getLatestReleaseFromGitHub()
27+
);
28+
29+
if (error) {
30+
const msg = createErrorMessage(
31+
error,
32+
"Failed to fetch version number from GitHub"
33+
);
34+
console.error(msg);
35+
return;
36+
}
37+
2438
const memoryVersion = getMemory();
2539

2640
version = currentVersion;

0 commit comments

Comments
 (0)