Skip to content

Commit 29a734c

Browse files
committed
fix: error handling for missing schema
1 parent 475436d commit 29a734c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

frontend/app/view/codeeditor/schemaendpoints.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@ const allFilepaths: Map<string, Array<string>> = new Map();
1414
allFilepaths.set(`${getWebServerEndpoint()}/schema/settings.json`, [`${getApi().getConfigDir()}/settings.json`]);
1515

1616
async function getSchemaEndpointInfo(endpoint: string): Promise<EndpointInfo> {
17-
const data = await fetch(endpoint);
18-
const fullSchema: object = await data.json();
19-
const schemaRef = fullSchema?.["$ref"];
20-
const schema = fullSchema?.[schemaRef];
17+
let schema: Object;
18+
try {
19+
const data = await fetch(endpoint);
20+
const fullSchema: object = await data.json();
21+
const schemaRef: string = fullSchema?.["$ref"];
22+
schema = fullSchema?.[schemaRef];
23+
} catch (e) {
24+
console.log("cannot find schema:", e);
25+
schema = {};
26+
}
2127
const fileMatch = allFilepaths.get(endpoint) ?? [];
2228

2329
return {

0 commit comments

Comments
 (0)