I have this in my DocumentDB stored proc:
function mySproc(doc) {
let context = getContext();
let collection = context.getCollection();
let collectionLink = collection.getSelfLink();
try {
if (!collection.createDocument(collectionLink, doc, handler))
return;
numCreated++;
} catch (e) {
// Never happens.
}
}
Unfortunately, if I intentionally throw within the handler
callback, it doesn't get caught in the catch block. It ends up halting the entire stored proc execution. Is that expected--does the callback have its own scope of some sort?