Skip to content

Commit

Permalink
Add CancellationError (#10035)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsmfm authored Sep 27, 2021
1 parent dba8794 commit ce996cc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/core/src/common/cancellation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -952,7 +952,8 @@ export function createAPIFactory(
SemanticTokensEdit,
ColorThemeKind,
SourceControlInputBoxValidationType,
FileDecoration
FileDecoration,
CancellationError
};
};
}
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,10 @@ declare module '@theia/plugin' {
onDidDelete: Event<Uri>;
}

export class CancellationError extends Error {
constructor();
}

/**
* A cancellation token used to request cancellation on long running
* or asynchronous task.
Expand Down

0 comments on commit ce996cc

Please sign in to comment.