Which of the below is the acceptable way to do what I am trying to accomplish?
exports.onExecutePostLogin = async (event, api) => {
const ApiKey = event.secrets.CIVICRM_API_KEY;
// Should I do this?
if (!ApiKey) {
console.log( `APIKEY is not configured` );
api.access.deny('APIKEY is not configured');
return;
}
// Or this?
if (!ApiKey) {
throw new Error('APIKEY is not configured');
}
};
Essentially, can I call api.access.deny() anywhere in my code and essentially process.exit(1) happens? Because if I throw an Exception we come to a full stop and I dont have potentially undefined things being passed around (which ultimately leads to a less discoverable exception thrown).