Skip to content

Commit 84bb468

Browse files
committed
Hide Postgres error messages
1 parent 94ee6b4 commit 84bb468

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

services/features.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@ let featureDatabasePool;
1313

1414
function executeQuery(query, params, callback) {
1515
featureDatabasePool.connect((err, client, done) => {
16-
if (err) return callback(err);
16+
if (err) {
17+
console.error(err);
18+
return callback(new ServiceError(HttpStatus.INTERNAL_SERVER_ERROR, "Error connecting to the features DB"));
19+
}
1720

1821
client.query(query, params, (err, results) => {
1922
done();
2023

21-
if (err)
22-
return callback(err);
23-
else
24+
if (err) {
25+
console.error(err);
26+
return callback(new ServiceError(HttpStatus.INTERNAL_SERVER_ERROR, "Error querying the features DB"));
27+
} else {
2428
return callback(null, resultsToFeatures(results));
29+
}
2530
});
2631
});
2732
}

services/postgres.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ function init(callback) {
1010
const connectionString = process.env.FEATURES_CONNECTION_STRING;
1111

1212
if (!connectionString) {
13-
const err = new ServiceError(HttpStatus.INTERNAL_SERVER_ERROR, "FEATURES_CONNECTION_STRING configuration not provided as environment variable");
14-
return callback(err);
13+
return callback(new ServiceError(HttpStatus.INTERNAL_SERVER_ERROR, "Environment not set up to connect to DB"));
1514
}
1615

1716
const params = url.parse(connectionString);

services/visits.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,20 @@ function deleteByUserId(userId, callback) {
4848

4949
function executeQuery(query, params, callback) {
5050
featureTablePool.connect((err, client, done) => {
51-
if (err) return callback(err);
51+
if (err) {
52+
console.error(err);
53+
return callback(new ServiceError(HttpStatus.INTERNAL_SERVER_ERROR, "Error connecting to the visits DB"));
54+
}
5255

5356
client.query(query, params, (err, results) => {
5457
done();
5558

56-
if (err)
57-
return callback(err);
58-
else
59+
if (err) {
60+
console.error(err);
61+
return callback(new ServiceError(HttpStatus.INTERNAL_SERVER_ERROR, "Error querying the visits DB"));
62+
} else {
5963
return callback(null, resultsToVisits(results));
64+
}
6065
});
6166
});
6267
}

0 commit comments

Comments
 (0)