Skip to content

Commit 74ddcc3

Browse files
fix: improved UX, skipping internal known error (#62)
1 parent 96594c9 commit 74ddcc3

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

constants/constants.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const ERROR_MESSAGE = {
2+
aborted: 'Query execution was aborted',
3+
};
4+
5+
module.exports = {
6+
ERROR_MESSAGE,
7+
};

reverse_engineering/helpers/connectionHelper.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const exec = util.promisify(require('child_process').exec);
55
const { spawn } = require('child_process');
66
const { buildQuery, queryType } = require('./queryHelper');
77
const localization = require('../../localization/en.json');
8+
const { ERROR_MESSAGE } = require('../../constants/constants');
89

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

179+
const getAbortedError = () => new Error(ERROR_MESSAGE.aborted);
180+
178181
return {
179182
execute: (query, signal) => {
180183
return new Promise((resolve, reject) => {
181184
if (signal?.aborted) {
182-
return reject(new Error('Query execution was aborted'));
185+
return reject(getAbortedError());
183186
}
184187

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

202205
if (signal) {

reverse_engineering/helpers/prepareError.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
const prepareError = error => ({
2-
message: error.message,
3-
stack: error.stack,
4-
type: error.type,
5-
customMsgCode: error.customMsgCode,
6-
});
1+
const { ERROR_MESSAGE } = require('../../constants/constants');
2+
3+
const prepareError = error => {
4+
if (error.message === ERROR_MESSAGE.aborted) {
5+
return null;
6+
}
7+
8+
return {
9+
message: error.message,
10+
stack: error.stack,
11+
type: error.type,
12+
customMsgCode: error.customMsgCode,
13+
};
14+
};
715

816
module.exports = {
917
prepareError,

0 commit comments

Comments
 (0)