I forgot to add that in my example. I updated it to handle general errors as well.
Essentially it’s just about adding an exception branch to each of the okThenX functions, and return a general error with the exception from that. That will wrap all the JS code in a try/catch to catch any unexpected errors and forward them to the result.
You could also add an exception branch yourself to the switch that handles the final result, and all of that code will be wrapped in a try/catch.
EDIT: This reply makes me feel like I’m an LLM… “I forgot to add blah. I updated the example to blah”
.