Hi again,

I removed all unnecessary methods like all logging handling and renamed 
some methods. Here is a shorter example which is much more powerful than 
the current domain module:


var scope = require('error'); //my module

scope.addErrorListener([Error], function (err, next) {
  console.log("Error handled: " + err);
  //next(); //call next errorListener otherwise print to cerr and abort the 
process
});

scope.run(function () {
  require('fs').readFile("file.txt", this.intercept(function () {
    var innerScope = this.create();
    innerScope.addErrorListener(Error, function (err, next) {
      console.log("innerScope caught: " + err);
      next(); //lets re-throw it!
    });
    
    innerScope.run(function () {
      throw new Error("My custom error"); //will be caught by innerScope,
    });
  }));
});


It works like regular exceptions, if the current scope does not handle it, 
will it just go up one error until it will abort the process and print out 
the error together with the stack trace. This design would be much better 
in an asynchronous environment like node.js, specially if we extend the 
current domain module to support this. Thoughts?


Cheers!

On Wednesday, July 11, 2012 9:00:18 PM UTC+2, Jeff Barczewski wrote:
>
> @idleman, I didn't go through in detail what you have illustrated here or 
> how you plan to implement, but wanted you to maybe backup a step and 
> discuss what your value proposition for this project is beyond what the new 
> Node.js domains brings to the table. 
>
> Any robust error handling solution needs to take advantage of the best 
> hooks node.js can provide especially when asynchronous IO is involved, so 
> you should take a look at the new Domains introduced in 0.8. Your solution 
> should most likely use or build on Domains.
>
> http://nodejs.org/api/domain.html
>
> If domains doesn't go far enough with what you are needing/wanting, please 
> identify the gaps and how your project would provide them.
>
> Also, if your needs are universal for many people, then they could 
> potentially be added to domains and everyone benefits.
>
> So my suggestion is to look at domains, identify any gaps and communicate 
> back to this list for input, then your framework could potentially take on 
> the role of implementing those gaps on top of what node already provides 
> (in domains).
>
>
> All the best,
>
> Jeff
>
>
>
>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to