Skip to content

Commit

Permalink
feat: add error handling to config functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cfu288 committed Jun 30, 2024
1 parent a75e77d commit 026d79a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions apps/web/src/environments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ const Config = z.object({
type Config = z.infer<typeof Config>;

export const getConfig = (): Config => {
return Config.parse(Configuration);
try {
return Config.parse(Configuration);
} catch (err) {
if (err instanceof z.ZodError) {
console.log(err.issues);
}
throw err;
}
};

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

export const getRedirectUri = () => {
const config = Config.parse(Configuration);
return config.REDIRECT_URI || config.PUBLIC_URL;
try {
const config = Config.parse(Configuration);
return config.REDIRECT_URI || config.PUBLIC_URL;
} catch (err) {
if (err instanceof z.ZodError) {
console.log(err.issues);
}
throw err;
}
};

0 comments on commit 026d79a

Please sign in to comment.