oracle - reporting error line numbers

This commit is contained in:
Jan Prochazka 2024-08-06 08:47:10 +02:00
parent aad4df419c
commit 33552e30b7

View File

@ -154,10 +154,12 @@ const drivers = driverBases.map(driverBase => ({
});
query.on('error', error => {
console.log('ERROR', error);
const { message, lineNumber, procName } = error;
const { message, offset, procName } = error;
// get line number from string s of character at offset
const lineNumber = (sql.substring(0, offset).match(/\n/g) || []).length;
options.info({
message,
offset,
line: lineNumber,
procedure: procName,
time: new Date(),
@ -176,8 +178,11 @@ const drivers = driverBases.map(driverBase => ({
client.execute(sql, (err, res) => {
if (err) {
console.log('Error query', err, sql);
const lineNumber = (sql.substring(0, err.offset).match(/\n/g) || []).length;
options.info({
message: err.message,
line: lineNumber,
offset: err.offset,
time: new Date(),
severity: 'error',
});