mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 18:26:00 +00:00
import error reporting
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const EnsureStreamHeaderStream = require('../utility/EnsureStreamHeaderStream');
|
||||
const ColumnMapTransformStream = require('../utility/ColumnMapTransformStream');
|
||||
const streamPipeline = require('../utility/streamPipeline');
|
||||
const { getLogger, extractErrorLogData, RowProgressReporter } = require('dbgate-tools');
|
||||
const { getLogger, extractErrorLogData, RowProgressReporter, extractErrorMessage } = require('dbgate-tools');
|
||||
const logger = getLogger('copyStream');
|
||||
const stream = require('stream');
|
||||
|
||||
@@ -66,7 +66,7 @@ async function copyStream(input, output, options) {
|
||||
process.send({
|
||||
msgtype: 'copyStreamError',
|
||||
copyStreamError: {
|
||||
message: err.message,
|
||||
message: extractErrorMessage(err),
|
||||
...err,
|
||||
},
|
||||
});
|
||||
@@ -76,7 +76,7 @@ async function copyStream(input, output, options) {
|
||||
msgtype: 'progress',
|
||||
progressName,
|
||||
status: 'error',
|
||||
errorMessage: err.message,
|
||||
errorMessage: extractErrorMessage(err),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ const logger = getLogger('tableWriter');
|
||||
* @param {boolean} options.truncate - truncate table before insert
|
||||
* @param {boolean} options.createIfNotExists - create table if not exists
|
||||
* @param {boolean} options.commitAfterInsert - commit transaction after insert
|
||||
* @param {string} options.progressName - name for reporting progress
|
||||
* @param {any} options.targetTableStructure - target table structure (don't analyse if given)
|
||||
* @returns {Promise<writerType>} - writer object
|
||||
*/
|
||||
@@ -26,7 +27,20 @@ async function tableWriter({ connection, schemaName, pureName, driver, systemCon
|
||||
}
|
||||
const dbhan = systemConnection || (await connectUtility(driver, connection, 'write'));
|
||||
|
||||
return await driver.writeTable(dbhan, { schemaName, pureName }, options);
|
||||
try {
|
||||
return await driver.writeTable(dbhan, { schemaName, pureName }, options);
|
||||
} catch (err) {
|
||||
if (options.progressName) {
|
||||
process.send({
|
||||
msgtype: 'progress',
|
||||
progressName: options.progressName,
|
||||
status: 'error',
|
||||
errorMessage: err.message,
|
||||
});
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = tableWriter;
|
||||
|
||||
Reference in New Issue
Block a user