Use CancellationError to avoid logging of cancels as errors (#7477)

This commit is contained in:
Colen Garoutte-Carson
2021-05-06 16:31:24 -07:00
committed by GitHub
parent b89e45a4b6
commit 5297166d4f
2 changed files with 3 additions and 3 deletions
@@ -24,7 +24,7 @@ export class FoldingRangeProvider implements vscode.FoldingRangeProvider {
token.onCancellationRequested(e => this.client.abortRequest(id));
const ranges: GetFoldingRangesResult = await this.client.languageClient.sendRequest(GetFoldingRangesRequest, params);
if (ranges.canceled) {
throw new Error('Request for providing folding ranges is cancelled.');
throw new vscode.CancellationError();
} else {
const result: vscode.FoldingRange[] = [];
ranges.ranges.forEach((r) => {
@@ -32,10 +32,10 @@ export class SemanticTokensProvider implements vscode.DocumentSemanticTokensProv
};
const tokensResult: GetSemanticTokensResult = await this.client.languageClient.sendRequest(GetSemanticTokensRequest, params);
if (tokensResult.canceled) {
throw new Error('Request for providing semantic tokens is cancelled.');
throw new vscode.CancellationError();
} else {
if (tokensResult.fileVersion !== openFileVersions.get(uriString)) {
throw new Error('The semantic tokens are not related to the current version of the document.');
throw new vscode.CancellationError();
} else {
const builder: vscode.SemanticTokensBuilder = new vscode.SemanticTokensBuilder(this.client.semanticTokensLegend);
tokensResult.tokens.forEach((token) => {