On Wednesday, November 14, 2012 at 3:26 PM, Adam Crabtree wrote: > FWIW, this is exactly why I built trycatch > (https://npmjs.org/package/trycatch). trycatch works for all the use cases > listed here: > > * Call once, and all proceeding async calls and uncaught exceptions are > properly handled > * Nesting works as expected (exactly how nesting synchronous try/catch blocks > would behave) > * Not reliant on 3rd party modules to implement in order to work > * Long stack traces > * Works properly with EventEmitter > > Granted, trycatch ATM doesn't offer the resource cleanup, but in theory it > could be combined with domains to accomplish this just fine. I may do so when > I get the chance now that domains are little more stable, assuming they > wouldn't interfere. In the other thread you mentioned above > (https://groups.google.com/forum/?fromgroups#!topic/nodejs/RphMf98jcgA) where > I'm discussing a few of these things, I included the following example where > domain nesting fails, but succeeds just fine with trycatch: > > https://gist.github.com/4075399 > > Nothing against domains. I just find them to be cumbersome and to not solve > the problems I face, esp. wrt. libraries not properly handling > Errors/exceptions. I made a few changes to your gist (the error wasn't getting handed off properly, and the domain error-handling code was looking for the properties that trycatch adds to the Error object):
https://gist.github.com/4075562 In this example, everything behaves as it should (I believe) -- domainFoo calls thirdPartyFoo, so thirdPartyFoo's domain is active when the error is raised, and handles it, and then the callbacks are invoked, with the error ending up in the callback passed to domainFoo, as it should. Did my changes alter the point you were trying to make? If so, how? F -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
