When a map/reduce has an error in the map or reduc...
# suitescript
a
When a map/reduce has an error in the map or reduce stage, what happens? Does it just go the catch and break out immediately of the rest of the iteration? Does it still go to the summary? I am creating many records and I created a rollback functionality but I am not sure where I would call it. I could just put it in catch of the map or reduce, but I want to make sure I am not calling it more than once
j
If you add a try/catch in the map phase you can capture the error
a
If an uncaught error is thrown during the map or reduce stage, the default behavior is that the current function invocation ends, even if incomplete, and the map or reduce job moves on to other key/value pairs that require processing.
So I am unclear on this? For a user based error, what if this is caught? It goes to the catch of the map and then the script dies or it still goes the summarize?
m
Since you can configure it's behavior there isn't a single answer to what happens. However by default it will stop processing the current key and move to the next key. The answer of where to handle the error again depends on the logic. Most likely you would iterate through the errors in the Summarize stage and do your handling there.
a
It sounds like from the docs, it only moves to the next key if it is uncaught. I am wondering what happens if it is caught
m
If the error is caught then it isn't an error since it doesn't bubble up to the stage.
a
Meaning a caught error will still make it to the summarize?
m
No a caught error will not be known to any other stage.