DBF reader - log errors

This commit is contained in:
SPRINX0\prochazka
2025-01-07 18:28:19 +01:00
parent 48eb8badec
commit a156ec942b

View File

@@ -4,6 +4,10 @@ const fs = require('fs');
const stream = require('stream'); const stream = require('stream');
const { DBFFile } = require('dbffile'); const { DBFFile } = require('dbffile');
const { getLogger, extractErrorLogData } = global.DBGATE_PACKAGES['dbgate-tools'];
const logger = getLogger('dbfReader');
let dbgateApi; let dbgateApi;
function getFieldType(field) { function getFieldType(field) {
@@ -55,7 +59,7 @@ async function reader({ fileName, encoding = 'ISO-8859-1', includeDeletedRecords
pass.write({ pass.write({
__isStreamHeader: true, __isStreamHeader: true,
columns, columns,
}) });
let readedRows = 0; let readedRows = 0;
// Read each record and push it into the stream // Read each record and push it into the stream
@@ -71,6 +75,7 @@ async function reader({ fileName, encoding = 'ISO-8859-1', includeDeletedRecords
pass.end(); pass.end();
} catch (error) { } catch (error) {
// If any error occurs, destroy the stream with the error // If any error occurs, destroy the stream with the error
logger.error(extractErrorLogData(error), 'Error reading DBF file');
pass.end(); pass.end();
} }
})(); })();