From 33552e30b74dea1506598798cc14b207664b391d Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Tue, 6 Aug 2024 08:47:10 +0200 Subject: [PATCH] oracle - reporting error line numbers --- plugins/dbgate-plugin-oracle/src/backend/drivers.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/dbgate-plugin-oracle/src/backend/drivers.js b/plugins/dbgate-plugin-oracle/src/backend/drivers.js index 31a56657..8ff5cb24 100644 --- a/plugins/dbgate-plugin-oracle/src/backend/drivers.js +++ b/plugins/dbgate-plugin-oracle/src/backend/drivers.js @@ -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', });