Skip to content

Commit c7c2b8f

Browse files
committed
add try catch to selfcode parsing
1 parent 7e645d0 commit c7c2b8f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/aiProviders/continue/continueContextProvider.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ export class db2ContextProvider implements IContextProvider {
4040
return currentJob?.job.options.libraries[0] || "QGPL";
4141
};
4242

43+
tryParseJson(row: SelfCodeNode) {
44+
try {
45+
return JSON.parse(row.INITIAL_STACK as unknown as string);
46+
} catch (e) {
47+
return [];
48+
}
49+
}
50+
4351
async getSelfCodes(selected: JobInfo): Promise<SelfCodeNode[] | undefined> {
4452
const current_job = selected.job.id;
4553
const content = `
@@ -80,7 +88,7 @@ export class db2ContextProvider implements IContextProvider {
8088
if (result.success) {
8189
const data: SelfCodeNode[] = result.data.map((row) => ({
8290
...row,
83-
INITIAL_STACK: JSON.parse(row.INITIAL_STACK as unknown as string),
91+
INITIAL_STACK: this.tryParseJson(row),
8492
}));
8593

8694
return data;

0 commit comments

Comments
 (0)