Skip to content

Commit baf7844

Browse files
committed
chore: capture config setting errors in sentry
1 parent 7952acc commit baf7844

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

frontend/src/ts/config-validation.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as Notifications from "./elements/notifications";
22
import { ZodSchema, z } from "zod";
3+
import { captureException } from "./sentry";
34

45
// function isConfigKeyValid(name: string): boolean {
56
// if (name === null || name === undefined || name === "") return false;
@@ -12,19 +13,15 @@ export function invalid(
1213
val: unknown,
1314
customMessage?: string
1415
): void {
15-
if (customMessage === undefined) {
16-
Notifications.add(
17-
`Invalid value for ${key} (${val}). Please try to change this setting again.`,
18-
-1
19-
);
20-
} else {
21-
Notifications.add(
22-
`Invalid value for ${key} (${val}). ${customMessage}`,
23-
-1
24-
);
16+
let message = `Invalid value for ${key} (${val}). Please try to change this setting again.`;
17+
18+
if (customMessage !== undefined) {
19+
message = `Invalid value for ${key} (${val}). ${customMessage}`;
2520
}
2621

27-
console.error(`Invalid value key ${key} value ${val} type ${typeof val}`);
22+
Notifications.add(message, -1);
23+
console.error(message);
24+
captureException(new Error(message));
2825
}
2926

3027
export function isConfigValueValid<T>(

0 commit comments

Comments
 (0)