Skip to content

Commit 7e26b00

Browse files
committed
error handling: fix error handling when global_config.json is in incorrect format
Fixes #1403. I added a dialog box error function, that gets thrown whenever json format is found to be incorrect.
1 parent 13f3818 commit 7e26b00

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

app/common/enterprise-util.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {dialog} from "electron/main";
12
import fs from "node:fs";
23
import path from "node:path";
34
import process from "node:process";
@@ -6,6 +7,7 @@ import {z} from "zod";
67

78
import {enterpriseConfigSchemata} from "./config-schemata.js";
89
import Logger from "./logger-util.js";
10+
import * as Messages from "./messages.js";
911

1012
type EnterpriseConfig = {
1113
[Key in keyof typeof enterpriseConfigSchemata]: z.output<
@@ -40,6 +42,8 @@ function reloadDatabase(): void {
4042
.partial()
4143
.parse(data);
4244
} catch (error: unknown) {
45+
const {title, content} = Messages.enterpriseInvalidJson(enterpriseFile);
46+
dialog.showErrorBox(title, content);
4347
logger.log("Error while JSON parsing global_config.json: ");
4448
logger.log(error);
4549
}

app/common/messages.ts

+9
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,12 @@ export function orgRemovalError(url: string): DialogBoxError {
3636
content: "Please contact your system administrator.",
3737
};
3838
}
39+
40+
export function enterpriseInvalidJson(
41+
pathToConfigFile: string,
42+
): DialogBoxError {
43+
return {
44+
title: "Invalid JSON",
45+
content: `Correct the invalid JSON format in global_config.json.\nIt can be found in:\n${pathToConfigFile}`,
46+
};
47+
}

0 commit comments

Comments
 (0)