I have nested promises when call is done the inner promise return a reject and the outer promise catch that reject but does not return it and the process ends.
function simpleExecute(sql, bindParams, user_ldap) {
return new Promise(function (resolve, reject) {
var options = {
user: user_ldap,
outFormat: oracledb.OBJECT
}
return getConnection(options)
.then(function (connection) {
return execute(sql, bindParams, options, connection)
.then(function (results) {
resolve(results);
process.nextTick(function () {
releaseConnection(connection);
});
}, (rej) => {
return reject(rej); <----- Reject here
}).catch(function (err) {
if (err) {
console.log(err);
return reject(err);
}
process.nextTick(function () {
releaseConnection(connection);
});
});
}, (rej) => {
return reject(rej);
});
}, (rej) => {
return reject(rej);
}).catch(function (err) {
return reject(err); <---- catch here and no return!!
});
}
and my caller is
await ids.then(res => {
console.log(res);
}, rej => {
console.log(rej);
}).catch(err => {
console.log(err);
});
in the caller function, I can not get any response from the promise when its rejected. any help is appreciated.