mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 13:23:58 +00:00
log driver errors, even when they are sent to client
This commit is contained in:
@@ -63,9 +63,7 @@ async function handleIncrementalRefresh(forceSend) {
|
|||||||
loadingModel = true;
|
loadingModel = true;
|
||||||
const driver = requireEngineDriver(storedConnection);
|
const driver = requireEngineDriver(storedConnection);
|
||||||
setStatusName('checkStructure');
|
setStatusName('checkStructure');
|
||||||
const newStructure = await checkedAsyncCall(
|
const newStructure = await checkedAsyncCall(driver.analyseIncremental(dbhan, analysedStructure, serverVersion));
|
||||||
driver.analyseIncremental(dbhan, analysedStructure, serverVersion)
|
|
||||||
);
|
|
||||||
analysedTime = new Date().getTime();
|
analysedTime = new Date().getTime();
|
||||||
if (newStructure != null) {
|
if (newStructure != null) {
|
||||||
analysedStructure = newStructure;
|
analysedStructure = newStructure;
|
||||||
@@ -202,57 +200,64 @@ async function handleSqlSelect({ msgid, select }) {
|
|||||||
return handleQueryData({ msgid, sql: dmp.s }, true);
|
return handleQueryData({ msgid, sql: dmp.s }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDriverDataCore(msgid, callMethod) {
|
async function handleDriverDataCore(msgid, callMethod, { logName }) {
|
||||||
await waitConnected();
|
await waitConnected();
|
||||||
const driver = requireEngineDriver(storedConnection);
|
const driver = requireEngineDriver(storedConnection);
|
||||||
try {
|
try {
|
||||||
const result = await callMethod(driver);
|
const result = await callMethod(driver);
|
||||||
process.send({ msgtype: 'response', msgid, result });
|
process.send({ msgtype: 'response', msgid, result });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
logger.error(err, `Error when handling message ${logName}`);
|
||||||
process.send({ msgtype: 'response', msgid, errorMessage: err.message });
|
process.send({ msgtype: 'response', msgid, errorMessage: err.message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSchemaList({ msgid }) {
|
async function handleSchemaList({ msgid }) {
|
||||||
logger.debug('Loading schema list');
|
logger.debug('Loading schema list');
|
||||||
return handleDriverDataCore(msgid, driver => driver.listSchemas(dbhan));
|
return handleDriverDataCore(msgid, driver => driver.listSchemas(dbhan), { logName: 'listSchemas' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleCollectionData({ msgid, options }) {
|
async function handleCollectionData({ msgid, options }) {
|
||||||
return handleDriverDataCore(msgid, driver => driver.readCollection(dbhan, options));
|
return handleDriverDataCore(msgid, driver => driver.readCollection(dbhan, options), { logName: 'readCollection' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleLoadKeys({ msgid, root, filter }) {
|
async function handleLoadKeys({ msgid, root, filter }) {
|
||||||
return handleDriverDataCore(msgid, driver => driver.loadKeys(dbhan, root, filter));
|
return handleDriverDataCore(msgid, driver => driver.loadKeys(dbhan, root, filter), { logName: 'loadKeys' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleExportKeys({ msgid, options }) {
|
async function handleExportKeys({ msgid, options }) {
|
||||||
return handleDriverDataCore(msgid, driver => driver.exportKeys(dbhan, options));
|
return handleDriverDataCore(msgid, driver => driver.exportKeys(dbhan, options), { logName: 'exportKeys' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleLoadKeyInfo({ msgid, key }) {
|
async function handleLoadKeyInfo({ msgid, key }) {
|
||||||
return handleDriverDataCore(msgid, driver => driver.loadKeyInfo(dbhan, key));
|
return handleDriverDataCore(msgid, driver => driver.loadKeyInfo(dbhan, key), { logName: 'loadKeyInfo' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleCallMethod({ msgid, method, args }) {
|
async function handleCallMethod({ msgid, method, args }) {
|
||||||
return handleDriverDataCore(msgid, driver => {
|
return handleDriverDataCore(
|
||||||
|
msgid,
|
||||||
|
driver => {
|
||||||
if (storedConnection.isReadOnly) {
|
if (storedConnection.isReadOnly) {
|
||||||
throw new Error('Connection is read only, cannot call custom methods');
|
throw new Error('Connection is read only, cannot call custom methods');
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureExecuteCustomScript(driver);
|
ensureExecuteCustomScript(driver);
|
||||||
return driver.callMethod(dbhan, method, args);
|
return driver.callMethod(dbhan, method, args);
|
||||||
});
|
},
|
||||||
|
{ logName: `callMethod:${method}` }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleLoadKeyTableRange({ msgid, key, cursor, count }) {
|
async function handleLoadKeyTableRange({ msgid, key, cursor, count }) {
|
||||||
return handleDriverDataCore(msgid, driver => driver.loadKeyTableRange(dbhan, key, cursor, count));
|
return handleDriverDataCore(msgid, driver => driver.loadKeyTableRange(dbhan, key, cursor, count), {
|
||||||
|
logName: 'loadKeyTableRange',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleLoadFieldValues({ msgid, schemaName, pureName, field, search }) {
|
async function handleLoadFieldValues({ msgid, schemaName, pureName, field, search }) {
|
||||||
return handleDriverDataCore(msgid, driver =>
|
return handleDriverDataCore(msgid, driver => driver.loadFieldValues(dbhan, { schemaName, pureName }, field, search), {
|
||||||
driver.loadFieldValues(dbhan, { schemaName, pureName }, field, search)
|
logName: 'loadFieldValues',
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureExecuteCustomScript(driver) {
|
function ensureExecuteCustomScript(driver) {
|
||||||
|
|||||||
Reference in New Issue
Block a user