Some promise fixes (#8216)

* Some promise fixes

* changes to how we're logging errors

* Fix the tests

* Fix a few other issues
This commit is contained in:
Amir Omidi
2019-11-05 11:50:39 -08:00
committed by GitHub
parent 5a392dfd58
commit 1b88c10197
6 changed files with 73 additions and 66 deletions

View File

@@ -6,9 +6,7 @@
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import * as types from 'vs/base/common/types';
import * as azdata from 'azdata';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
import { IRestoreService, IRestoreDialogController, TaskExecutionMode } from 'sql/platform/restore/common/restoreService';
import { OptionsDialog } from 'sql/workbench/browser/modal/optionsDialog';
@@ -64,7 +62,7 @@ export class RestoreService implements IRestoreService {
return new Promise<azdata.RestoreResponse>((resolve, reject) => {
const providerResult = this.getProvider(connectionUri);
if (providerResult) {
TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.RestoreRequested, { provider: providerResult.providerName });
TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.RestoreRequested, { provider: providerResult.providerName }).catch((e) => this.logService.error(e));
providerResult.provider.restore(connectionUri, restoreInfo).then(result => {
resolve(result);
}, error => {
@@ -149,7 +147,8 @@ export class RestoreDialogController implements IRestoreDialogController {
@IConnectionManagementService private _connectionService: IConnectionManagementService,
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
@ITaskService private _taskService: ITaskService
@ITaskService private _taskService: ITaskService,
@ILogService private _logService: ILogService,
) {
}
@@ -165,11 +164,14 @@ export class RestoreDialogController implements IRestoreDialogController {
const self = this;
let connectionProfile = self._connectionService.getConnectionProfile(self._ownerUri);
let activeNode = self._objectExplorerService.getObjectExplorerNode(connectionProfile);
this._taskService.onTaskComplete(response => {
this._taskService.onTaskComplete(async response => {
if (result.taskId === response.id && this.isSuccessfulRestore(response) && activeNode) {
self._objectExplorerService.refreshTreeNode(activeNode.getSession(), activeNode).then(result => {
self._objectExplorerService.getServerTreeView().refreshTree();
});
try {
await self._objectExplorerService.refreshTreeNode(activeNode.getSession(), activeNode);
await self._objectExplorerService.getServerTreeView().refreshTree();
} catch (e) {
this._logService.error(e);
}
}
});
let restoreDialog = this._restoreDialogs[this._currentProvider];
@@ -279,7 +281,7 @@ export class RestoreDialogController implements IRestoreDialogController {
}
private handleOnClose(): void {
this._connectionService.disconnect(this._ownerUri);
this._connectionService.disconnect(this._ownerUri).catch((e) => this._logService.error(e));
}
private handleOnCancel(): void {