Because I have not got any response from the last post, I post again, for 
hopefully someone can answer me. Forget about what I said in the first 
post, it was embarrassing.

The community would probably benefit if we extend (node.js) domain module 
to support polymorphism. It should not require much work  (only a simple 
wrapper around the current domain, like I have done private) and it is 
fully possible. See previous example too get a point on what I mean.

The simple domain.on('error', ...) is not enough. This comes from why 
throw/catch was first invented, to skip all error handling and unwind the 
stack until it can be handled. The domain module should probably do the 
same, and if the error is not handled, show some nice error message:

//pseudo domain

domain.addErrorListener(Error, function(err, next) {
  //will only be invoked by instances of Error
  console.log("domain caught");
  next(); //would generate a nice error message and stop the process, if no 
more error listener is found.
});
domain.run(function() {
  //this is just used here to show how great it could be receive the 
closest domain (domain)
  var foo = this.create();
  foo.addErrorListener([EvalError, SyntaxError, ReferenceError,TypeError], 
function(err, next) {
    //will only be invoked by instances of EvalError, SyntaxError, 
ReferenceError and TypeError
    //An empty array or [[]] should be used for listen for array objects
    console.log("foo caught ");
    next();
   });
  foo.run(function() {
    setTimeout(function() {
      noneExistentFunction(); //stimulate asynchronous operation 
    } 1000);
  });
});

SHOULD OUTPUT:
foo caught
domain caught

Like you can see, next should be equivalent too re-throw an exception 
within a try statement. Please someone in the dev team answer me now. is 
this not a very good feature to have? The regular domain.on('error') can 
stay the same, just add the functionality to support polymorphism like I 
showed above. I can upload the code I personally use, it is small, however 
I don't use the method add and dispose, so they does not exist.

Thank in advance!


-- 
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

Reply via email to