From 14d771736b3d3cf8b5769ab32f772b3821a9875a Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Mon, 30 Aug 2021 12:03:33 +0000 Subject: [PATCH] Add CancellationError --- packages/core/src/common/cancellation.ts | 7 +++++++ packages/plugin-ext/src/plugin/plugin-context.ts | 5 +++-- packages/plugin/src/theia.d.ts | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/core/src/common/cancellation.ts b/packages/core/src/common/cancellation.ts index 117955c34a6be..a0af2f373e0ce 100644 --- a/packages/core/src/common/cancellation.ts +++ b/packages/core/src/common/cancellation.ts @@ -48,6 +48,13 @@ export namespace CancellationToken { }); } +export class CancellationError extends Error { + constructor() { + super('Canceled'); + this.name = this.message; + } +} + class MutableToken implements CancellationToken { private _isCancelled: boolean = false; diff --git a/packages/plugin-ext/src/plugin/plugin-context.ts b/packages/plugin-ext/src/plugin/plugin-context.ts index e71522501ed40..fd9dc1337705d 100644 --- a/packages/plugin-ext/src/plugin/plugin-context.ts +++ b/packages/plugin-ext/src/plugin/plugin-context.ts @@ -149,7 +149,7 @@ import { LanguagesExtImpl } from './languages'; import { fromDocumentSelector, pluginToPluginInfo, fromGlobPattern } from './type-converters'; import { DialogsExtImpl } from './dialogs'; import { NotificationExtImpl } from './notification'; -import { CancellationToken } from '@theia/core/lib/common/cancellation'; +import { CancellationToken, CancellationError } from '@theia/core/lib/common/cancellation'; import { score } from '@theia/callhierarchy/lib/common/language-selector'; import { MarkdownString } from './markdown-string'; import { TreeViewsExtImpl } from './tree/tree-views'; @@ -952,7 +952,8 @@ export function createAPIFactory( SemanticTokensEdit, ColorThemeKind, SourceControlInputBoxValidationType, - FileDecoration + FileDecoration, + CancellationError }; }; } diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index 5f51e2761150a..ecd9009ffcf59 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -2018,6 +2018,10 @@ declare module '@theia/plugin' { onDidDelete: Event; } + export class CancellationError extends Error { + constructor(); + } + /** * A cancellation token used to request cancellation on long running * or asynchronous task.