File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -49,8 +49,15 @@ export async function readConfigFile(filePath: string, contextWindow: number): P
4949 * @returns The parsed configuration object
5050 */
5151export async function readJsonConfigFile < T > ( filePath : string , contextWindow : number ) : Promise < T > {
52- const content = await readConfigFile ( filePath , contextWindow )
53- return JSON . parse ( content ) as T
52+ try {
53+ const content = await readConfigFile ( filePath , contextWindow )
54+ return JSON . parse ( content ) as T
55+ } catch ( error ) {
56+ if ( error instanceof SyntaxError ) {
57+ throw new Error ( `Invalid JSON in config file ${ filePath } : ${ error . message } ` )
58+ }
59+ throw new Error ( `Failed to read config file ${ filePath } : ${ error instanceof Error ? error . message : String ( error ) } ` )
60+ }
5461}
5562
5663/**
You can’t perform that action at this time.
0 commit comments