Hi all, no matter how hard I tried .. I can't seem...
# suitescript
d
Hi all, no matter how hard I tried .. I can't seem to
throw
an exception in the MAP stage of a Map/Reduce ... and have that exception show up in the SUMMARY stage in the context.mapSummary.errors . It should no?
e
It should, yes; how are you reading/parsing the errors?
d
Copy code
let mapErrorCount = 0;
context.mapSummary.errors.iterator().each((key, error, executionNo) => {
    mapErrorCount++;
    log.error('summarize - mapSummary.errors', { key, error, executionNo });
    return true;
});
e
Copied and pasted your code; it worked fine for me. The full script:
Copy code
define([], function () {
  function getInputData() {
    return {type:'suiteql', query: 'SELECT * FROM customrecord_sma_config'}
  }

  function map (context) {
    throw { name: 'an-error', message: 'a message' } 
  }

  function summarize (context) {
    context.mapSummary.errors.iterator().each((key, error, executionNo) => {
      log.error('key=', key)
      log.error('error=', error)
      log.error('executionNo', executionNo)
      log.error('summarize - mapSummary.errors', { key, error, executionNo })
      return true
    })
  }
  
  return { getInputData, map, summarize }
})
Logs:
Maybe the
throw
is not actually escaping the
map
? Getting caught instead? Guessing at this point
d
Sorry, lost sight of this.
😵‍💫 1