diff --git a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts index d96ad9d32a5..f2e90bd136d 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts @@ -15,6 +15,7 @@ import { assertType } from 'vs/base/common/types'; import { URI } from 'vs/base/common/uri'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IWriteFileOptions, IFileStatWithMetadata } from 'vs/platform/files/common/files'; +import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IRevertOptions, ISaveOptions, IUntypedEditorInput } from 'vs/workbench/common/editor'; import { EditorModel } from 'vs/workbench/common/editor/editorModel'; import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel'; @@ -241,8 +242,30 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF throw new CancellationError(); } - const stat = await serializer.save(this._notebookModel.uri, this._notebookModel.versionId, options, token); - return stat; + try { + const stat = await serializer.save(this._notebookModel.uri, this._notebookModel.versionId, options, token); + return stat; + } catch (error) { + if (!token.isCancellationRequested) { + type notebookSaveErrorData = { + isRemote: boolean; + versionMismatch: boolean; + }; + type notebookSaveErrorClassification = { + owner: 'amunger'; + comment: 'Detect if we are having issues saving a notebook on the Extension Host'; + isRemote: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Whether the save is happening on a remote file system' }; + versionMismatch: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'If the error was because of a version mismatch' }; + }; + const telemetry = {} as ITelemetryService; + telemetry.publicLogError2('notebook/SaveError', { + isRemote: this._notebookModel.uri.scheme === Schemas.vscodeRemote, + versionMismatch: error instanceof Error && error.message === 'Document version mismatch' + }); + } + + throw error; + } }; }