mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 23:06:01 +00:00
handled error when getting DB sever version
This commit is contained in:
@@ -4,6 +4,8 @@ const { connectUtility } = require('../utility/connectUtility');
|
|||||||
const { handleProcessCommunication } = require('../utility/processComm');
|
const { handleProcessCommunication } = require('../utility/processComm');
|
||||||
const { pickSafeConnectionInfo } = require('../utility/crypting');
|
const { pickSafeConnectionInfo } = require('../utility/crypting');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
const { getLogger, extractErrorLogData } = require('dbgate-tools');
|
||||||
|
const logger = getLogger('connectProcess');
|
||||||
|
|
||||||
const formatErrorDetail = (e, connection) => `${e.stack}
|
const formatErrorDetail = (e, connection) => `${e.stack}
|
||||||
|
|
||||||
@@ -23,12 +25,22 @@ function start() {
|
|||||||
try {
|
try {
|
||||||
const driver = requireEngineDriver(connection);
|
const driver = requireEngineDriver(connection);
|
||||||
const dbhan = await connectUtility(driver, connection, 'app');
|
const dbhan = await connectUtility(driver, connection, 'app');
|
||||||
const res = await driver.getVersion(dbhan);
|
let version = {
|
||||||
|
version: 'Unknown',
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
version = await driver.getVersion(dbhan);
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(extractErrorLogData(err), 'Error getting DB server version');
|
||||||
|
version = {
|
||||||
|
version: 'Unknown',
|
||||||
|
};
|
||||||
|
}
|
||||||
let databases = undefined;
|
let databases = undefined;
|
||||||
if (requestDbList) {
|
if (requestDbList) {
|
||||||
databases = await driver.listDatabases(dbhan);
|
databases = await driver.listDatabases(dbhan);
|
||||||
}
|
}
|
||||||
process.send({ msgtype: 'connected', ...res, databases });
|
process.send({ msgtype: 'connected', ...version, databases });
|
||||||
await driver.close(dbhan);
|
await driver.close(dbhan);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|||||||
@@ -120,10 +120,15 @@ function setStatusName(name) {
|
|||||||
|
|
||||||
async function readVersion() {
|
async function readVersion() {
|
||||||
const driver = requireEngineDriver(storedConnection);
|
const driver = requireEngineDriver(storedConnection);
|
||||||
const version = await driver.getVersion(dbhan);
|
try {
|
||||||
logger.debug(`Got server version: ${version.version}`);
|
const version = await driver.getVersion(dbhan);
|
||||||
process.send({ msgtype: 'version', version });
|
logger.debug(`Got server version: ${version.version}`);
|
||||||
serverVersion = version;
|
serverVersion = version;
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(extractErrorLogData(err), 'Error getting DB server version');
|
||||||
|
serverVersion = { version: 'Unknown' };
|
||||||
|
}
|
||||||
|
process.send({ msgtype: 'version', version: serverVersion });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleConnect({ connection, structure, globalSettings }) {
|
async function handleConnect({ connection, structure, globalSettings }) {
|
||||||
|
|||||||
@@ -46,7 +46,13 @@ async function handleRefresh() {
|
|||||||
|
|
||||||
async function readVersion() {
|
async function readVersion() {
|
||||||
const driver = requireEngineDriver(storedConnection);
|
const driver = requireEngineDriver(storedConnection);
|
||||||
const version = await driver.getVersion(dbhan);
|
let version;
|
||||||
|
try {
|
||||||
|
version = await driver.getVersion(dbhan);
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(extractErrorLogData(err), 'Error getting DB server version');
|
||||||
|
version = { version: 'Unknown' };
|
||||||
|
}
|
||||||
process.send({ msgtype: 'version', version });
|
process.send({ msgtype: 'version', version });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user