I'm not the biggest fan of try/catch in JS, but I'm willing to accept the control flow changes for certain situations. I thought it might be worth it for looping over async stuff with async/await.
e.g.
function doThings(thingFns, done) {
try {
thingFns.forEach(doThing);
} catch (error) {
done(error);
}
}
async function doThing(thingFn) {
await util.promisify(thingFn)();
}
That catch won't actually catch errors from with doThing, though. You have to catch them from within doThing. However, you cannot throw the error from within doThing and have it caught by doThings, either. (Perhaps you could if you were running the loop with a traditional for?)
But either way, whatever. That's just too much fiddliness. If I just call each callback via
d3-queue (about 120 lines of very readable code!), it's way easier to debug.