From 49f6cb4b406e88ebecee6552b61cd347166dbda2 Mon Sep 17 00:00:00 2001 From: Wroud Date: Wed, 15 Jul 2020 12:26:55 +0300 Subject: [PATCH] chore(plugin-sql-editor): improve error message CB-204 --- .../src/SqlEditorNavigatorService.ts | 15 +++++++++++---- .../plugin-sql-editor/src/SqlEditorTabService.ts | 6 ++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditorNavigatorService.ts b/webapp/packages/plugin-sql-editor/src/SqlEditorNavigatorService.ts index 09dd36bf5c..280f78e565 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditorNavigatorService.ts +++ b/webapp/packages/plugin-sql-editor/src/SqlEditorNavigatorService.ts @@ -124,11 +124,13 @@ export class SqlEditorNavigatorService { if (data.type === SQLEditorNavigationAction.create) { const tabOptions = await this.createNewEditor(data.connectionId, data.catalogId, data.schemaId); + const connectionInfo = this.connectionInfoResource.get(data.connectionId || ''); + if (tabOptions) { tabInfo.openNewTab(tabOptions); } else { this.notificationService.logError({ - title: `Failed to create editor for ${data.connectionId} connection`, + title: `Failed to create editor for ${connectionInfo?.name || data.connectionId} connection`, }); } return; @@ -168,10 +170,15 @@ export class SqlEditorNavigatorService { connectionId = Array.from(this.connectionInfoResource.data.values())[0].id; } - const connection = await this.connectionAuthService.auth(connectionId); + try { + const connection = await this.connectionAuthService.auth(connectionId); - if (!connection?.connected) { - return null; + if (!connection?.connected) { + return null; + } + } catch (exception) { + this.notificationService.logException(exception); + throw exception; } await this.sqlDialectInfoService.loadSqlDialectInfo(connectionId); diff --git a/webapp/packages/plugin-sql-editor/src/SqlEditorTabService.ts b/webapp/packages/plugin-sql-editor/src/SqlEditorTabService.ts index f4744c683b..5d08d6781f 100644 --- a/webapp/packages/plugin-sql-editor/src/SqlEditorTabService.ts +++ b/webapp/packages/plugin-sql-editor/src/SqlEditorTabService.ts @@ -112,6 +112,12 @@ export class SqlEditorTabService { if (!connection?.connected) { return false; } + } catch (exception) { + this.notificationService.logException(exception); + return false; + } + + try { // try to create new context first const context = await this.createSqlContext(connectionId);