diff --git a/src/sql/base/browser/ui/breadcrumb/breadcrumb.component.ts b/src/sql/base/browser/ui/breadcrumb/breadcrumb.component.ts index fd8be969a1..43d002d202 100644 --- a/src/sql/base/browser/ui/breadcrumb/breadcrumb.component.ts +++ b/src/sql/base/browser/ui/breadcrumb/breadcrumb.component.ts @@ -52,7 +52,7 @@ export class BreadcrumbComponent implements OnInit, OnDestroy { this._changeRef.detectChanges(); } - public route(link: any[]): void { - this._router.navigate(link); + public route(link: any[]): Promise { + return this._router.navigate(link); } } diff --git a/src/sql/platform/restore/browser/restoreServiceImpl.ts b/src/sql/platform/restore/browser/restoreServiceImpl.ts index afec28b0d3..659165fa50 100644 --- a/src/sql/platform/restore/browser/restoreServiceImpl.ts +++ b/src/sql/platform/restore/browser/restoreServiceImpl.ts @@ -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((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 { diff --git a/src/sql/workbench/parts/objectExplorer/browser/connectionTreeAction.ts b/src/sql/workbench/parts/objectExplorer/browser/connectionTreeAction.ts index 8170923697..51f1a79c8b 100644 --- a/src/sql/workbench/parts/objectExplorer/browser/connectionTreeAction.ts +++ b/src/sql/workbench/parts/objectExplorer/browser/connectionTreeAction.ts @@ -7,21 +7,18 @@ import { localize } from 'vs/nls'; import { Action } from 'vs/base/common/actions'; import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile'; import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; -import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; -import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService'; import { ServerTreeView } from 'sql/workbench/parts/objectExplorer/browser/serverTreeView'; import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup'; -import * as TaskUtilities from 'sql/workbench/browser/taskUtilities'; import { ITree } from 'vs/base/parts/tree/browser/tree'; import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService'; import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode'; import Severity from 'vs/base/common/severity'; import { ObjectExplorerActionsContext } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions'; -import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService'; import { UNSAVED_GROUP_ID } from 'sql/platform/connection/common/constants'; import { IServerGroupController } from 'sql/platform/serverGroup/common/serverGroupController'; +import { ILogService } from 'vs/platform/log/common/log'; export class RefreshAction extends Action { @@ -36,21 +33,21 @@ export class RefreshAction extends Action { private element: IConnectionProfile | TreeNode, @IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IObjectExplorerService private _objectExplorerService: IObjectExplorerService, - @IErrorMessageService private _errorMessageService: IErrorMessageService + @IErrorMessageService private _errorMessageService: IErrorMessageService, + @ILogService private _logService: ILogService ) { super(id, label); this._tree = tree; } - public run(): Promise { + public async run(): Promise { let treeNode: TreeNode; if (this.element instanceof ConnectionProfile) { let connection: ConnectionProfile = this.element; if (this._connectionManagementService.isConnected(undefined, connection)) { treeNode = this._objectExplorerService.getObjectExplorerNode(connection); if (treeNode === undefined) { - this._objectExplorerService.updateObjectExplorerNodes(connection.toIConnectionProfile()).then(() => { - treeNode = this._objectExplorerService.getObjectExplorerNode(connection); - }); + await this._objectExplorerService.updateObjectExplorerNodes(connection.toIConnectionProfile()); + treeNode = this._objectExplorerService.getObjectExplorerNode(connection); } } } else if (this.element instanceof TreeNode) { @@ -58,26 +55,26 @@ export class RefreshAction extends Action { } if (treeNode) { - return this._tree.collapse(this.element).then(() => { - return this._objectExplorerService.refreshTreeNode(treeNode.getSession(), treeNode).then(() => { - - return this._tree.refresh(this.element).then(() => { - return this._tree.expand(this.element); - }, refreshError => { - return Promise.resolve(true); - }); - }, error => { + try { + await this._tree.collapse(this.element); + try { + await this._objectExplorerService.refreshTreeNode(treeNode.getSession(), treeNode); + } catch (error) { this.showError(error); - return Promise.resolve(true); - }); - }, collapseError => { - return Promise.resolve(true); - }); + return true; + } + await this._tree.refresh(this.element); + return this._tree.expand(this.element); + } catch (ex) { + this._logService.error(ex); + return true; + } } - return Promise.resolve(true); + return true; } private showError(errorMessage: string) { + this._logService.error(errorMessage); if (this._errorMessageService) { this._errorMessageService.showDialog(Severity.Error, '', errorMessage); } @@ -99,29 +96,23 @@ export class DisconnectConnectionAction extends Action { super(id, label); } - run(actionContext: ObjectExplorerActionsContext): Promise { - return new Promise((resolve, reject) => { - if (!this._connectionProfile) { - resolve(true); + async run(actionContext: ObjectExplorerActionsContext): Promise { + if (!this._connectionProfile) { + return true; + } + if (this._connectionManagementService.isProfileConnected(this._connectionProfile)) { + let profileImpl = this._connectionProfile as ConnectionProfile; + if (profileImpl) { + profileImpl.isDisconnecting = true; } - if (this._connectionManagementService.isProfileConnected(this._connectionProfile)) { - let profileImpl = this._connectionProfile as ConnectionProfile; - if (profileImpl) { - profileImpl.isDisconnecting = true; - } - this._connectionManagementService.disconnect(this._connectionProfile).then((value) => { - if (profileImpl) { - profileImpl.isDisconnecting = false; - } - resolve(true); - } - ).catch(disconnectError => { - reject(disconnectError); - }); - } else { - resolve(true); + await this._connectionManagementService.disconnect(this._connectionProfile); + if (profileImpl) { + profileImpl.isDisconnecting = false; } - }); + return true; + } else { + return true; + } } } @@ -141,7 +132,7 @@ export class AddServerAction extends Action { this.class = 'add-server-action'; } - public run(element: ConnectionProfileGroup): Promise { + public async run(element: ConnectionProfileGroup): Promise { let connection: IConnectionProfile = element === undefined ? undefined : { connectionName: undefined, serverName: undefined, @@ -159,8 +150,8 @@ export class AddServerAction extends Action { saveProfile: true, id: element.id }; - this._connectionManagementService.showConnectionDialog(undefined, undefined, connection); - return Promise.resolve(true); + await this._connectionManagementService.showConnectionDialog(undefined, undefined, connection); + return true; } } @@ -180,9 +171,9 @@ export class AddServerGroupAction extends Action { this.class = 'add-server-group-action'; } - public run(): Promise { - this.serverGroupController.showCreateGroupDialog(); - return Promise.resolve(true); + public async run(): Promise { + await this.serverGroupController.showCreateGroupDialog(); + return true; } } diff --git a/src/sql/workbench/parts/objectExplorer/test/browser/connectionTreeActions.test.ts b/src/sql/workbench/parts/objectExplorer/test/browser/connectionTreeActions.test.ts index 1e854676ca..1833833f67 100644 --- a/src/sql/workbench/parts/objectExplorer/test/browser/connectionTreeActions.test.ts +++ b/src/sql/workbench/parts/objectExplorer/test/browser/connectionTreeActions.test.ts @@ -32,7 +32,7 @@ import { UNSAVED_GROUP_ID, mssqlProviderName } from 'sql/platform/connection/com import { $ } from 'vs/base/browser/dom'; import { OEManageConnectionAction } from 'sql/workbench/parts/dashboard/browser/dashboardActions'; import { IViewsService, IView, ViewContainer, IViewDescriptorCollection } from 'vs/workbench/common/views'; -import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; +import { ConsoleLogService } from 'vs/platform/log/common/log'; suite('SQL Connection Tree Action tests', () => { let errorMessageService: TypeMoq.Mock; @@ -43,6 +43,8 @@ suite('SQL Connection Tree Action tests', () => { callStack: undefined }; let capabilitiesService = new TestCapabilitiesService(); + const logService = new ConsoleLogService(); + setup(() => { errorMessageService = TypeMoq.Mock.ofType(TestErrorMessageService, TypeMoq.MockBehavior.Loose); let nothing: void; @@ -427,7 +429,8 @@ suite('SQL Connection Tree Action tests', () => { connection, connectionManagementService.object, objectExplorerService.object, - undefined); + undefined, + logService); connectionAction.run().then((value) => { connectionManagementService.verify(x => x.isConnected(undefined, TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce()); @@ -514,7 +517,8 @@ suite('SQL Connection Tree Action tests', () => { connection, connectionManagementService.object, objectExplorerService.object, - undefined); + undefined, + logService); connectionAction.run().then((value) => { connectionManagementService.verify(x => x.isConnected(undefined, TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce()); diff --git a/src/sql/workbench/services/bootstrap/browser/bootstrapService.ts b/src/sql/workbench/services/bootstrap/browser/bootstrapService.ts index de198dd358..fb7cd57134 100644 --- a/src/sql/workbench/services/bootstrap/browser/bootstrapService.ts +++ b/src/sql/workbench/services/bootstrap/browser/bootstrapService.ts @@ -11,6 +11,7 @@ import { Trace } from 'vs/platform/instantiation/common/instantiationService'; import { values } from 'vs/base/common/map'; import { IModuleFactory, IBootstrapParams } from 'sql/workbench/services/bootstrap/common/bootstrapParams'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { ILogService } from 'vs/platform/log/common/log'; const selectorCounter = new Map(); @@ -64,6 +65,15 @@ export function bootstrapAngular(service: IInstantiationService, moduleType: if (callbackSetModule) { callbackSetModule(moduleRef); } + }).catch((e) => { + service.invokeFunction((accessor) => { + const logService = accessor.get(ILogService); + if (!logService) { + console.error(e); + return; + } + logService.error(e); + }); }); return uniqueSelectorString; diff --git a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts index d16d0d7539..24223ce2dd 100644 --- a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts +++ b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts @@ -281,7 +281,7 @@ export class ObjectExplorerService implements IObjectExplorerService { this._serverTreeView.deleteObjectExplorerNodeAndRefreshTree(connection).then(() => { this.sendUpdateNodeEvent(connection, session.errorMessage); connection.isDisconnecting = true; - this._connectionManagementService.disconnect(connection).then((value) => { + this._connectionManagementService.disconnect(connection).then(() => { connection.isDisconnecting = false; }).catch((e) => this.logService.error(e)); });