Skip to content

Commit 05ecfa2

Browse files
author
Ruben van Leeuwen
committed
Restores try catch in useRefParser
1 parent d544fbe commit 05ecfa2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

frontend/packages/pydantic-forms/src/core/hooks/useRefParser.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ export function useRefParser(
1919
return useSWR<PydanticFormSchemaParsed | undefined>(
2020
[id, rawJsonSchema],
2121
async ([, source]) => {
22-
if (!source) {
23-
return undefined;
22+
try {
23+
if (!source) {
24+
return undefined;
25+
}
26+
const parsedSchema = (await $RefParser.dereference(source, {
27+
mutateInputSchema: false,
28+
})) as unknown as PydanticFormSchemaParsed;
29+
return parsedSchema;
30+
} catch (error) {
31+
console.error(error);
32+
throw new Error('Could not parse JSON references');
2433
}
25-
const parsedSchema = (await $RefParser.dereference(source, {
26-
mutateInputSchema: false,
27-
})) as unknown as PydanticFormSchemaParsed;
28-
return parsedSchema;
2934
},
3035
{
3136
fallback: {},

0 commit comments

Comments
 (0)