@@ -233,7 +233,7 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
233
233
234
234
// Override save behavior to avoid transferring the buffer across the wire 3 times
235
235
if ( saveWithReducedCommunication ) {
236
- this . setSaveDelegate ( ) . catch ( console . error ) ;
236
+ this . setSaveDelegate ( ) . catch ( error => this . _notebookLogService . error ( 'WorkingCopyModel' , `Failed to set save delegate: ${ error } ` ) ) ;
237
237
}
238
238
}
239
239
@@ -247,7 +247,12 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
247
247
248
248
if ( ! serializer ) {
249
249
this . _notebookLogService . info ( 'WorkingCopyModel' , 'No serializer found for notebook model, checking if provider still needs to be resolved' ) ;
250
- serializer = await this . getNotebookSerializer ( ) ;
250
+ serializer = await this . getNotebookSerializer ( ) . catch ( error => {
251
+ this . _notebookLogService . error ( 'WorkingCopyModel' , `Failed to get notebook serializer: ${ error } ` ) ;
252
+ // The serializer was set initially but somehow is no longer available
253
+ this . save = undefined ;
254
+ throw new NotebookSaveError ( 'Failed to get notebook serializer' ) ;
255
+ } ) ;
251
256
}
252
257
253
258
if ( token . isCancellationRequested ) {
@@ -257,11 +262,11 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
257
262
const stat = await serializer . save ( this . _notebookModel . uri , this . _notebookModel . versionId , options , token ) ;
258
263
return stat ;
259
264
} catch ( error ) {
260
- if ( ! token . isCancellationRequested ) {
265
+ if ( ! token . isCancellationRequested && error . name !== 'Canceled' ) {
261
266
type notebookSaveErrorData = {
262
267
isRemote : boolean ;
263
268
isIPyNbWorkerSerializer : boolean ;
264
- error : Error ;
269
+ error : string ;
265
270
} ;
266
271
type notebookSaveErrorClassification = {
267
272
owner : 'amunger' ;
@@ -271,10 +276,11 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
271
276
error : { classification : 'SystemMetaData' ; purpose : 'PerformanceAndHealth' ; comment : 'Info about the error that occurred' } ;
272
277
} ;
273
278
const isIPynb = this . _notebookModel . viewType === 'jupyter-notebook' || this . _notebookModel . viewType === 'interactive' ;
279
+ const errorMessage = error . name === 'NotebookSaveError' ? error . message : 'Unknown error' ;
274
280
this . _telemetryService . publicLogError2 < notebookSaveErrorData , notebookSaveErrorClassification > ( 'notebook/SaveError' , {
275
281
isRemote : this . _notebookModel . uri . scheme === Schemas . vscodeRemote ,
276
282
isIPyNbWorkerSerializer : isIPynb && this . _configurationService . getValue < boolean > ( 'ipynb.experimental.serialization' ) ,
277
- error : error
283
+ error : errorMessage
278
284
} ) ;
279
285
}
280
286
@@ -313,7 +319,8 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
313
319
async getNotebookSerializer ( ) : Promise < INotebookSerializer > {
314
320
const info = await this . _notebookService . withNotebookDataProvider ( this . notebookModel . viewType ) ;
315
321
if ( ! ( info instanceof SimpleNotebookProviderInfo ) ) {
316
- throw new Error ( 'CANNOT open file notebook with this provider' ) ;
322
+ const message = 'CANNOT open notebook with this provider' ;
323
+ throw new NotebookSaveError ( message ) ;
317
324
}
318
325
319
326
return info . serializer ;
@@ -348,3 +355,10 @@ export class NotebookFileWorkingCopyModelFactory implements IStoredFileWorkingCo
348
355
}
349
356
350
357
//#endregion
358
+
359
+ class NotebookSaveError extends Error {
360
+ constructor ( message : string ) {
361
+ super ( message ) ;
362
+ this . name = 'NotebookSaveError' ;
363
+ }
364
+ }
0 commit comments