Skip to content

Commit 026d79a

Browse files
committed
feat: add error handling to config functions
1 parent a75e77d commit 026d79a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Diff for: apps/web/src/environments/index.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ const Config = z.object({
2121
type Config = z.infer<typeof Config>;
2222

2323
export const getConfig = (): Config => {
24-
return Config.parse(Configuration);
24+
try {
25+
return Config.parse(Configuration);
26+
} catch (err) {
27+
if (err instanceof z.ZodError) {
28+
console.log(err.issues);
29+
}
30+
throw err;
31+
}
2532
};
2633

2734
const OnPatientConfig = z.object({
@@ -33,6 +40,13 @@ export const getOnPatientConfig = () => {
3340
};
3441

3542
export const getRedirectUri = () => {
36-
const config = Config.parse(Configuration);
37-
return config.REDIRECT_URI || config.PUBLIC_URL;
43+
try {
44+
const config = Config.parse(Configuration);
45+
return config.REDIRECT_URI || config.PUBLIC_URL;
46+
} catch (err) {
47+
if (err instanceof z.ZodError) {
48+
console.log(err.issues);
49+
}
50+
throw err;
51+
}
3852
};

0 commit comments

Comments
 (0)