File tree 1 file changed +14
-7
lines changed
arduino-ide-extension/src/node
1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -230,15 +230,22 @@ export class SketchesServiceImpl
230
230
private async loadRecentSketches ( ) : Promise < Record < string , number > > {
231
231
const fsPath = await this . recentSketchesFsPath ;
232
232
let data : Record < string , number > = { } ;
233
- const raw = await fs . readFile ( fsPath , {
234
- encoding : 'utf8' ,
235
- } ) ;
236
233
try {
237
- data = JSON . parse ( raw ) ;
234
+ const raw = await fs . readFile ( fsPath , {
235
+ encoding : 'utf8' ,
236
+ } ) ;
237
+ try {
238
+ data = JSON . parse ( raw ) ;
239
+ } catch ( err ) {
240
+ console . error (
241
+ `Could not parse recently opened sketches. Raw input was: ${ raw } `
242
+ ) ;
243
+ }
238
244
} catch ( err ) {
239
- console . error (
240
- `Could not parse recently opened sketches. Raw input was: ${ raw } `
241
- ) ;
245
+ if ( 'code' in err && err . code === 'ENOENT' ) {
246
+ return { } ;
247
+ }
248
+ throw err ;
242
249
}
243
250
return data ;
244
251
}
You can’t perform that action at this time.
0 commit comments