On Nov 12, 11:10 am, Marco Rogers <
marco.rog...@gmail.com> wrote:
> Ah, that's a very nice connection. The domains proposal does have elements
> that relate to sync try/catch. I like that characterization too. But I'm
> not sure we should call it tryCatch because domains can also be used in
> other ways. People will use it to manage arbitrary "domains" of state. Most
> commonly this will be a domain for request. This will allow, say express,
> to manage state for a single request and always be able to associate any
> execution state with the current request. But this isn't the same as
> localized execution where you want to try/catch.
>
> I guess maybe that's why people are also concerned about whether domains
> will nest in a parent child fashion. You'd have a request level domain,
> some domains internal to that for some complex try/catch behavior. Maybe
> some invisible domains below that, used by a data access layer. The more I
> think about it, the more confused I get when considering complex use cases.
> I hope it's ready for some practical testing soon.
Back on the "domains" proposal/solution...
I'd really like to see this be easy for local try/catch, as well as
whole-request:
function stuff() {
var tc = process.tryCatch(function(err) { // takes the error handler
finish(); // won't throw
})
io.async(..., function(err, result) {
if (err) throw err;
io.asinc(..., function(err, data) {
if (err) throw err;
finish(result, data); // may throw
tc.end(); // "end()" fires the end event
})
})
}
Also, will this work with non-core async libraries?