Map another ORA error to an NJS message

This commit is contained in:
Christopher Jones 2023-02-21 14:40:44 +11:00
parent 616479d2ae
commit 113cdd3399
3 changed files with 7 additions and 2 deletions

View File

@ -105,10 +105,12 @@ const ERR_INIT_ORACLE_CLIENT_ARGS = 90;
const ERR_MISSING_FILE = 91;
const ERR_INVALID_NUMBER_OF_CONNECTIONS = 92;
const ERR_EXEC_MODE_ONLY_FOR_DML = 95;
const ERR_POOL_HAS_BUSY_CONNECTIONS = 104;
// define mapping for ODPI-C errors that need to be wrapped with NJS errors
const adjustErrorXref = new Map();
adjustErrorXref.set("DPI-1063", ERR_EXEC_MODE_ONLY_FOR_DML);
adjustErrorXref.set("ORA-24422", ERR_POOL_HAS_BUSY_CONNECTIONS);
// define mapping for error messages
const messages = new Map();
@ -267,6 +269,8 @@ messages.set(ERR_INVALID_NUMBER_OF_CONNECTIONS,
'poolMax [%d] must be greater than or equal to poolMin [%d]');
messages.set(ERR_EXEC_MODE_ONLY_FOR_DML,
'setting batchErrors to true is only permitted with DML');
messages.set(ERR_POOL_HAS_BUSY_CONNECTIONS,
'connection pool cannot be closed because connections are busy');
//-----------------------------------------------------------------------------
// assert()
@ -523,6 +527,7 @@ module.exports = {
ERR_MISSING_FILE,
ERR_INVALID_NUMBER_OF_CONNECTIONS,
ERR_EXEC_MODE_ONLY_FOR_DML,
ERR_POOL_HAS_BUSY_CONNECTIONS,
assert,
assertArgCount,
assertParamPropBool,

View File

@ -70,7 +70,7 @@ describe('51. poolClose.js', function() {
const conn = await pool.getConnection();
await testsUtil.assertThrowsAsync(
async () => await pool.close(),
/ORA-24422:/
/NJS-104:/
);
await conn.close();
await pool.close();

View File

@ -80,7 +80,7 @@ describe('170. poolDrain.js', () => {
await pool.close();
} catch (err) {
should.exist(err);
(err.message).should.startWith('ORA-24422:');
(err.message).should.startWith('NJS-104:');
} finally {
await pool.close(0);
}