Skip to content

Commit 25dce8d

Browse files
committed
Updated pool._logStats to throw an error if the pool is not valid
1 parent 7ca0510 commit 25dce8d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/pool.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ function getConnection(getConnectionCb) {
146146
// (which is a C layer getter) an error will be thrown.
147147
if (!self._isValid) {
148148
if (getConnectionCb && typeof getConnectionCb === 'function') {
149-
getConnectionCb(new Error('NJS-002: invalid pool'));
149+
getConnectionCb(new Error(nodbUtil.getErrorMessage('NJS-002')));
150150
return;
151151
} else {
152-
throw new Error('NJS-002: invalid pool');
152+
throw new Error(nodbUtil.getErrorMessage('NJS-002'));
153153
}
154154
}
155155

@@ -236,8 +236,7 @@ function logStats() {
236236
var averageTimeInQueue;
237237

238238
if (!self._isValid) {
239-
console.log('_logStats must be called prior to terminating pool.');
240-
return;
239+
throw new Error(nodbUtil.getErrorMessage('NJS-002'));
241240
}
242241

243242
if (self._enableStats !== true) {

lib/util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var util = require('util');
2222
// errorMessages is a temporary duplication of error messages defined in the C
2323
// layer that will be removed once a function to fetch from the C layer is added.
2424
var errorMessages = {
25+
'NJS-002': 'NJS-002: invalid pool',
2526
'NJS-005': 'NJS-005: invalid value for parameter %d',
2627
'NJS-006': 'NJS-006: invalid type for parameter %d',
2728
'NJS-009': 'NJS-009: invalid number of parameters',

0 commit comments

Comments
 (0)