diff --git a/src/main/ipc-handlers/connection.ts b/src/main/ipc-handlers/connection.ts index 6f564b86..dbabb983 100644 --- a/src/main/ipc-handlers/connection.ts +++ b/src/main/ipc-handlers/connection.ts @@ -64,9 +64,9 @@ export default (connections: Record) => { username: conn.sshUser, password: conn.sshPass, port: conn.sshPort ? conn.sshPort : 22, - privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey).toString() : null, + privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey).toString() : undefined, passphrase: conn.sshPassphrase, - keepaliveInterval: conn.sshKeepAliveInterval ? conn.sshKeepAliveInterval*1000 : null + keepaliveInterval: conn.sshKeepAliveInterval ? conn.sshKeepAliveInterval*1000 : undefined }; } @@ -90,11 +90,12 @@ export default (connections: Record) => { return { status: 'success' }; } - catch (err) { + catch (error) { clearInterval(abortChecker); - - if (!isLocalAborted) - return { status: 'error', response: err.toString() }; + if (error instanceof AggregateError) + throw new Error(error.errors.reduce((acc, curr) => acc +' | '+ curr.message, '')); + else if (!isLocalAborted) + return { status: 'error', response: error.toString() }; else return { status: 'abort', response: 'Connection aborted' }; } diff --git a/src/main/libs/clients/MySQLClient.ts b/src/main/libs/clients/MySQLClient.ts index 24825e07..60827e50 100644 --- a/src/main/libs/clients/MySQLClient.ts +++ b/src/main/libs/clients/MySQLClient.ts @@ -173,7 +173,7 @@ export class MySQLClient extends BaseClient { remotePort: this._params.port }); - dbConfig.host = (this._ssh.config as SSHConfig[] & { host: string }).host; + dbConfig.host = this._ssh.config[0].host; dbConfig.port = tunnel.localPort; } catch (err) { @@ -302,6 +302,8 @@ export class MySQLClient extends BaseClient { await this.connect(); return this.getConnection(args, true); } + else if (error instanceof AggregateError) + throw new Error(error.errors.reduce((acc, curr) => acc +' | '+ curr.message, '')); else throw new Error(error.message); } diff --git a/src/main/libs/clients/PostgreSQLClient.ts b/src/main/libs/clients/PostgreSQLClient.ts index 3a2d9495..416239d2 100644 --- a/src/main/libs/clients/PostgreSQLClient.ts +++ b/src/main/libs/clients/PostgreSQLClient.ts @@ -179,7 +179,7 @@ export class PostgreSQLClient extends BaseClient { remotePort: this._params.port }); - dbConfig.host = (this._ssh.config as SSHConfig[] & { host: string }).host; + dbConfig.host = this._ssh.config[0].host; dbConfig.port = tunnel.localPort; } catch (err) { diff --git a/src/main/main.ts b/src/main/main.ts index 16995091..6c5f4128 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -132,11 +132,21 @@ app.on('ready', async () => { // mainWindow.webContents.openDevTools(); process.on('uncaughtException', error => { - mainWindow.webContents.send('unhandled-exception', error); + if (error instanceof AggregateError) { + for (const e of error.errors) + mainWindow.webContents.send('unhandled-exception', e); + } + else + mainWindow.webContents.send('unhandled-exception', error); }); process.on('unhandledRejection', error => { - mainWindow.webContents.send('unhandled-exception', error); + if (error instanceof AggregateError) { + for (const e of error.errors) + mainWindow.webContents.send('unhandled-exception', e); + } + else + mainWindow.webContents.send('unhandled-exception', error); }); });