Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions constants/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const ERROR_MESSAGE = {
aborted: 'Query execution was aborted',
};

module.exports = {
ERROR_MESSAGE,
};
7 changes: 5 additions & 2 deletions reverse_engineering/helpers/connectionHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const exec = util.promisify(require('child_process').exec);
const { spawn } = require('child_process');
const { buildQuery, queryType } = require('./queryHelper');
const localization = require('../../localization/en.json');
const { ERROR_MESSAGE } = require('../../constants/constants');

const SYSTEM_DATABASES = [
'val',
Expand Down Expand Up @@ -175,11 +176,13 @@ const createConnection = async (connectionInfo, sshService, logger) => {
const teradataClientPath = path.resolve(__dirname, '..', 'addons', 'TeradataClient.jar');
const teradataClientCommandArguments = buildCommand(teradataClientPath, connectionSettings);

const getAbortedError = () => new Error(ERROR_MESSAGE.aborted);

return {
execute: (query, signal) => {
return new Promise((resolve, reject) => {
if (signal?.aborted) {
return reject(new Error('Query execution was aborted'));
return reject(getAbortedError());
}

const queryArgument = createArgument('query', query);
Expand All @@ -196,7 +199,7 @@ const createConnection = async (connectionInfo, sshService, logger) => {
queryResult.kill('SIGTERM');
activeQueries.delete(queryResult);
}
reject(new Error('Query execution was aborted'));
reject(getAbortedError());
};

if (signal) {
Expand Down
20 changes: 14 additions & 6 deletions reverse_engineering/helpers/prepareError.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
const prepareError = error => ({
message: error.message,
stack: error.stack,
type: error.type,
customMsgCode: error.customMsgCode,
});
const { ERROR_MESSAGE } = require('../../constants/constants');

const prepareError = error => {
if (error.message === ERROR_MESSAGE.aborted) {
return null;
}

return {
message: error.message,
stack: error.stack,
type: error.type,
customMsgCode: error.customMsgCode,
};
};

module.exports = {
prepareError,
Expand Down