File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,18 @@ export class Controller {
66
66
}
67
67
68
68
const document = await vscode . workspace . openTextDocument ( selectedFileUri ) ;
69
- inputContent = JSON . parse ( document . getText ( ) ) ;
69
+ try {
70
+ inputContent = JSON . parse ( document . getText ( ) ) ;
71
+ }
72
+ catch ( error : any ) {
73
+ execution . replaceOutput ( [
74
+ new vscode . NotebookCellOutput ( [
75
+ vscode . NotebookCellOutputItem . text ( `Error parsing JSON file. Please check the file and try again. \n\n${ error . message } ` ) ,
76
+ ] )
77
+ ] ) ;
78
+ execution . end ( false , Date . now ( ) ) ;
79
+ return ;
80
+ }
70
81
71
82
if ( isMainThread ) {
72
83
const worker = new Worker ( join ( __filename , '../worker.js' ) , {
Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ export class Serializer implements vscode.NotebookSerializer {
50
50
let contents : RawNotebookCell [ ] = [ ] ;
51
51
52
52
for ( const cell of data . cells ) {
53
- const rawOutput = cell ?. outputs ?. at ( 0 ) ?. items [ 0 ] . data ;
53
+ const outputItem = cell ?. outputs ?. at ( 0 ) ?. items [ 0 ] ;
54
+ const rawOutput = outputItem ?. mime === 'text/x-json' ? outputItem . data : undefined ;
54
55
let output = undefined ;
55
56
if ( rawOutput ) {
56
57
output = JSON . parse ( new TextDecoder ( ) . decode ( rawOutput ) ) ;
You can’t perform that action at this time.
0 commit comments