diff --git a/src/vs/base/common/arrays.ts b/src/vs/base/common/arrays.ts index 4a2823c3671..8029a115b04 100644 --- a/src/vs/base/common/arrays.ts +++ b/src/vs/base/common/arrays.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { CancellationToken } from 'vs/base/common/cancellation'; -import { canceled } from 'vs/base/common/errors'; +import { CancellationError } from 'vs/base/common/errors'; import { ISplice } from 'vs/base/common/sequence'; /** @@ -257,7 +257,7 @@ export function topAsync(array: T[], compare: (a: T, b: T) => number, n: numb await new Promise(resolve => setTimeout(resolve)); // any other delay function would starve I/O } if (token && token.isCancellationRequested) { - throw canceled(); + throw new CancellationError(); } topStep(array, compare, result, i, m); } diff --git a/src/vs/editor/contrib/suggest/browser/suggest.ts b/src/vs/editor/contrib/suggest/browser/suggest.ts index 8cd3d553f6a..0632f522c3f 100644 --- a/src/vs/editor/contrib/suggest/browser/suggest.ts +++ b/src/vs/editor/contrib/suggest/browser/suggest.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { CancellationToken } from 'vs/base/common/cancellation'; -import { canceled, isCancellationError, onUnexpectedExternalError } from 'vs/base/common/errors'; +import { CancellationError, isCancellationError, onUnexpectedExternalError } from 'vs/base/common/errors'; import { FuzzyScore } from 'vs/base/common/filters'; import { DisposableStore, IDisposable, isDisposable } from 'vs/base/common/lifecycle'; import { StopWatch } from 'vs/base/common/stopwatch'; @@ -295,7 +295,7 @@ export async function provideSuggestionItems( if (token.isCancellationRequested) { disposables.dispose(); - return Promise.reject(canceled()); + return Promise.reject(new CancellationError()); } return new CompletionItemModel( diff --git a/src/vs/workbench/api/test/browser/extHostTypes.test.ts b/src/vs/workbench/api/test/browser/extHostTypes.test.ts index bcb92a1d701..4fa83071049 100644 --- a/src/vs/workbench/api/test/browser/extHostTypes.test.ts +++ b/src/vs/workbench/api/test/browser/extHostTypes.test.ts @@ -10,6 +10,7 @@ import { isWindows } from 'vs/base/common/platform'; import { assertType } from 'vs/base/common/types'; import { Mimes } from 'vs/base/common/mime'; import { MarshalledId } from 'vs/base/common/marshallingIds'; +import { CancellationError } from 'vs/base/common/errors'; function assertToJSON(a: any, expected: any) { const raw = JSON.stringify(a); @@ -565,6 +566,14 @@ suite('ExtHostTypes', function () { assert.ok(error instanceof types.FileSystemError); }); + test('CancellationError', function () { + // The CancellationError-type is used internally and exported as API. Make sure that at + // its name and message are `Canceled` + const err = new CancellationError(); + assert.strictEqual(err.name, 'Canceled'); + assert.strictEqual(err.message, 'Canceled'); + }); + test('CodeActionKind contains', () => { assert.ok(types.CodeActionKind.RefactorExtract.contains(types.CodeActionKind.RefactorExtract)); assert.ok(types.CodeActionKind.RefactorExtract.contains(types.CodeActionKind.RefactorExtract.append('other'))); diff --git a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts index 41ce758f5cf..9e3e00d91ee 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts @@ -27,7 +27,7 @@ import { assertType } from 'vs/base/common/types'; import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { StoredFileWorkingCopyState, IStoredFileWorkingCopy, IStoredFileWorkingCopyModel, IStoredFileWorkingCopyModelContentChangedEvent, IStoredFileWorkingCopyModelFactory, IStoredFileWorkingCopySaveEvent } from 'vs/workbench/services/workingCopy/common/storedFileWorkingCopy'; import { Disposable, DisposableStore } from 'vs/base/common/lifecycle'; -import { canceled } from 'vs/base/common/errors'; +import { CancellationError } from 'vs/base/common/errors'; import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { filter } from 'vs/base/common/objects'; @@ -631,7 +631,7 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF const bytes = await this._notebookSerializer.notebookToData(data); if (token.isCancellationRequested) { - throw canceled(); + throw new CancellationError(); } return bufferToStream(bytes); } @@ -642,7 +642,7 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF const data = await this._notebookSerializer.dataToNotebook(bytes); if (token.isCancellationRequested) { - throw canceled(); + throw new CancellationError(); } this._notebookModel.reset(data.cells, data.metadata, this._notebookSerializer.options); } @@ -674,7 +674,7 @@ export class NotebookFileWorkingCopyModelFactory implements IStoredFileWorkingCo const data = await info.serializer.dataToNotebook(bytes); if (token.isCancellationRequested) { - throw canceled(); + throw new CancellationError(); } const notebookModel = this._notebookService.createNotebookTextModel(info.viewType, resource, data, info.serializer.options);