Skip to content

Commit 4d1fcae

Browse files
committed
Fixes: Displays error when global_config.json is in incorrect format
Fixes #1404. I added a dialog box error function, that gets thrown whenever json format is found to be incorrect.
1 parent 13f3818 commit 4d1fcae

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

app/common/enterprise-util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import fs from "node:fs";
22
import path from "node:path";
33
import process from "node:process";
44

5+
import {dialog} from "@electron/remote";
56
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

Lines changed: 9 additions & 0 deletions
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)