modules/consentManagement.js
function exitModule(errMsg, hookConfig, extraArgs) {
  if (hookConfig.haveExited === false) {
    hookConfig.haveExited = true;

    let context = hookConfig.context;
    let args = hookConfig.args;
    let nextFn = hookConfig.nextFn;

    if (errMsg) {
      if (allowAuction) {
        utils.logWarn(errMsg + ' Resuming auction without consent data as per consentManagement config.', extraArgs);
        nextFn.apply(context, args);
      } else {
        utils.logError(errMsg + ' Canceling auction as per consentManagement config.', extraArgs);
        if (typeof hookConfig.bidsBackHandler === 'function') {
          hookConfig.bidsBackHandler();
        } else {
          utils.logError('Error executing bidsBackHandler');
        }
      }
    } else {
      nextFn.apply(context, args);
    }
  }
}
function exitModule(errMsg, hookConfig, extraArgs) {
  if (hookConfig.haveExited === false) {
    hookConfig.haveExited = true;

    let context = hookConfig.context;
    let args = hookConfig.args;
    let nextFn = hookConfig.nextFn;

    if (errMsg) {
      if (allowAuction) {
        utils.logWarn(errMsg + ' Resuming auction without consent data as per consentManagement config.', extraArgs);
        nextFn.apply(context, args);
      } else {
        utils.logError(errMsg + ' Canceling auction as per consentManagement config.', extraArgs);
        if (typeof hookConfig.bidsBackHandler === 'function') {
          hookConfig.bidsBackHandler();
        } else {
          utils.logError('Error executing bidsBackHandler');
        }
      }
    } else {
      nextFn.apply(context, args);
    }
  }
}
function exitModule ( errMsg , hookConfig , extraArgs ) { if ( hookConfig . haveExited === false ) { hookConfig . haveExited = true ; let context = hookConfig . context ; let args = hookConfig . args ; let nextFn = hookConfig . nextFn ; if ( errMsg ) { if ( allowAuction ) { utils . logWarn ( errMsg + ' Resuming auction without consent data as per consentManagement config.' , extraArgs ) ; nextFn . apply ( context , args ) ; } else { utils . logError ( errMsg + ' Canceling auction as per consentManagement config.' , extraArgs ) ; if ( typeof hookConfig . bidsBackHandler === 'function' ) { hookConfig . bidsBackHandler ( ) ; } else { utils . logError ( 'Error executing bidsBackHandler' ) ; } } } else { nextFn . apply ( context , args ) ; } } }
This function handles the exit logic for the module.
There are several paths in the module's logic to call this function and we only allow 1 of the 3 potential exits to happen before suppressing others.

We prevent multiple exits to avoid conflicting messages in the console depending on certain scenarios.
One scenario could be auction was canceled due to timeout with CMP being reached.
While the timeout is the accepted exit and runs first, the CMP's callback still tries to process the user's data (which normally leads to a good exit).
In this case, the good exit will be suppressed since we already decided to cancel the auction.

Three exit paths are:
1. good exit where auction runs (CMP data is processed normally).
2. bad exit but auction still continues (warning message is logged, CMP data is undefined and still passed along).
3. bad exit with auction canceled (error message is logged).
@param {string} errMsg optional; only to be used when there was a 'bad' exit.  String is a descriptive message for the failure/issue encountered.
@param {object} hookConfig contains module related variables (see comment in requestBidsHook function)
@param {object} extraArgs contains additional data that's passed along in the error/warning messages for easier debugging
This function handles the exit logic for the module . There are several paths in the module s logic to call this function and we only allow 1 of the 3 potential exits to happen before suppressing others .