Skip to content

Commit 28adf00

Browse files
committed
Simplify recent error message refactoring
1 parent 51c0b81 commit 28adf00

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

lib/util.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const errorMessages = {
4848
'NJS-002': 'NJS-002: invalid pool',
4949
'NJS-004': 'NJS-004: invalid value for property %s',
5050
'NJS-005': 'NJS-005: invalid value for parameter %d',
51-
'NJS-009': 'NJS-009: invalid number of parameters: %d passed but %d expected',
51+
'NJS-009': 'NJS-009: invalid number of parameters',
5252
'NJS-037': 'NJS-037: incompatible type of value provided',
5353
'NJS-040': 'NJS-040: connection request timeout. Request exceeded queueTimeout of %d',
5454
'NJS-041': 'NJS-041: cannot convert ResultSet to QueryStream after invoking methods',
@@ -61,7 +61,6 @@ const errorMessages = {
6161
'NJS-065': 'NJS-065: connection pool was closed',
6262
'NJS-067': 'NJS-067: a pre-built node-oracledb binary was not found for %s',
6363
'NJS-069': 'NJS-069: node-oracledb %s requires Node.js %s or later',
64-
'NJS-076': 'NJS-076: invalid number of parameters: %d passed but %d to %d expected',
6564
};
6665

6766
// getInstallURL returns a string with installation URL
@@ -154,14 +153,8 @@ module.exports.assert = assert;
154153
// optional parameters (range of number of parameters). If the number of
155154
// arguments is not within the given range, an error is thrown.
156155
function checkArgCount(args, minArgCount, maxArgCount) {
157-
if (args.length < minArgCount || args.length > maxArgCount) {
158-
if (minArgCount == maxArgCount) {
159-
throw new Error(getErrorMessage('NJS-009', args.length, minArgCount));
160-
} else {
161-
throw new Error (getErrorMessage('NJS-076', args.length,
162-
minArgCount, maxArgCount));
163-
}
164-
}
156+
if (args.length < minArgCount || args.length > maxArgCount)
157+
throw new Error(getErrorMessage('NJS-009'));
165158
}
166159

167160
module.exports.checkArgCount = checkArgCount;
@@ -212,8 +205,7 @@ function promisify(oracledb, func) {
212205

213206
// Check for invalid number or type of parameter(s) as they should be
214207
// eagerly thrown.
215-
if (errorCode === 'NJS-009' || errorCode === 'NJS-005' ||
216-
errorCode === 'NJS-076' ) {
208+
if (errorCode === 'NJS-009' || errorCode === 'NJS-005') {
217209
// Throwing the error outside of the promise wrapper so that its not
218210
// swallowed up as a rejection.
219211
process.nextTick(function() {

src/njsErrors.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static const char *njsErrorMessages[] = {
3333
"NJS-004: invalid value for property %s", // errInvalidPropertyValue
3434
"NJS-005: invalid value for parameter %d", // errInvalidParameterValue
3535
"NJS-007: invalid value for \"%s\" in parameter %d", // errInvalidPropertyValueInParam
36-
"NJS-009: invalid number of parameters: %d passed but %d expected", // errInvalidNumberOfParameters
36+
"NJS-009: invalid number of parameters", // errInvalidNumberOfParameters
3737
"NJS-010: unsupported data type %d in column %u", // errUnsupportedDataType
3838
"NJS-011: encountered bind value and type mismatch", // errBindValueAndTypeMismatch
3939
"NJS-012: encountered invalid bind data type in parameter %d", // errInvalidBindDataType
@@ -82,7 +82,6 @@ static const char *njsErrorMessages[] = {
8282
"NJS-073: cannot convert from JavaScript value to element of type %.*s", // errConvertToObjElement
8383
"NJS-074: cannot convert from JavaScript value to attribute \"%.*s\" of type \"%.*s\"", // errConvertToObjAttr
8484
"NJS-075: only one of connectString and connectionString can be used", // errDblConnectionString
85-
"NJS-076: invalid number of parameters: %d passed but %d to %d expected", //errInvalidNumberOfParametersRange
8685
};
8786

8887

src/njsModule.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ typedef enum {
192192
errConvertToObjElement,
193193
errConvertToObjAttr,
194194
errDblConnectionString,
195-
errInvalidNumberOfParametersRange,
196195

197196

198197
// New ones should be added here

test/stream2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe('14. stream2.js', function() {
225225
function() {
226226
connection.queryStream();
227227
},
228-
/NJS-076: invalid number of parameters/
228+
/NJS-009: invalid number of parameters/
229229
);
230230
done();
231231
});

0 commit comments

Comments
 (0)