Handle Promise errors caused by cancellation (#2420)

- Port of 34ca4c78b2
- This fixes issues where opening an editor send unhandled errors to the debug console, making it hard to debug issues.
This commit is contained in:
Kevin Cunnane
2018-09-05 14:01:09 -07:00
committed by GitHub
parent ac96919caf
commit b7f4f6af3a
6 changed files with 27 additions and 34 deletions

View File

@@ -57,7 +57,7 @@ export class HoverOperation<Result> {
private _firstWaitScheduler: RunOnceScheduler;
private _secondWaitScheduler: RunOnceScheduler;
private _loadingMessageScheduler: RunOnceScheduler;
private _asyncComputationPromise: CancelablePromise<void>;
private _asyncComputationPromise: CancelablePromise<Result>;
private _asyncComputationPromiseDone: boolean;
private _completeCallback: (r: Result) => void;
@@ -103,12 +103,11 @@ export class HoverOperation<Result> {
if (this._computer.computeAsync) {
this._asyncComputationPromiseDone = false;
this._asyncComputationPromise = createCancelablePromise(token => {
return this._computer.computeAsync(token).then((asyncResult: Result) => {
this._asyncComputationPromiseDone = true;
this._withAsyncResult(asyncResult);
}, (e) => this._onError(e));
});
this._asyncComputationPromise = createCancelablePromise(token => this._computer.computeAsync(token));
this._asyncComputationPromise.then((asyncResult: Result) => {
this._asyncComputationPromiseDone = true;
this._withAsyncResult(asyncResult);
}, (e) => this._onError(e));
} else {
this._asyncComputationPromiseDone = true;