Improve token authentication error messages
This commit is contained in:
parent
bdcaa8cbef
commit
bb027af2d2
|
@ -233,9 +233,7 @@ messages.set(ERR_POOL_RECONFIGURING,
|
|||
messages.set(ERR_POOL_STATISTICS_DISABLED,
|
||||
'pool statistics not enabled');
|
||||
messages.set(ERR_TOKEN_BASED_AUTH,
|
||||
'invalid or missing parameter with token based authentication. ' +
|
||||
'The token and privateKey attributes must contain values. ' +
|
||||
'Other credentials cannot be specified');
|
||||
'invalid access token');
|
||||
messages.set(ERR_POOL_TOKEN_BASED_AUTH,
|
||||
'invalid connection pool configuration with token based authentication. ' +
|
||||
'The homogeneous and externalAuth attributes must be set to true');
|
||||
|
@ -310,10 +308,13 @@ function assertPropValue(condition, propName) {
|
|||
//-----------------------------------------------------------------------------
|
||||
function throwErr(errorNum) {
|
||||
let baseText = messages.get(errorNum);
|
||||
if (!baseText)
|
||||
baseText = messages.get(ERR_INVALID_ERR_NUM);
|
||||
let args = [...arguments];
|
||||
if (!baseText) {
|
||||
args = [undefined, errorNum];
|
||||
errorNum = ERR_INVALID_ERR_NUM;
|
||||
baseText = messages.get(errorNum);
|
||||
}
|
||||
const errorNumStr = errorNum.toString().padStart(3, '0');
|
||||
const args = [...arguments];
|
||||
args[0] = `${ERR_PREFIX}-${errorNumStr}: ${baseText}`;
|
||||
throw new Error(util.format(...args));
|
||||
}
|
||||
|
@ -396,6 +397,9 @@ module.exports = {
|
|||
ERR_TOKEN_BASED_AUTH,
|
||||
ERR_POOL_TOKEN_BASED_AUTH,
|
||||
ERR_CONN_TOKEN_BASED_AUTH,
|
||||
ERR_TOKEN_HAS_EXPIRED,
|
||||
ERR_TOKEN_CALLBACK_DUP,
|
||||
ERR_NOT_IMPLEMENTED,
|
||||
assert,
|
||||
assertArgCount,
|
||||
assertParamPropValue,
|
||||
|
|
Loading…
Reference in New Issue