domain: fix error emit handling
There are a few errors in the logic of the new domain-specific emit
and a bit too much fanciness with the falling through try-catch logic. Fixed it all up and created a regression test.
Refs: https://github.com/nodejs/node/pull/17403
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
domain, events, test