Re:Fixing the callback spaghetti in node.js
by glenjamin on Thursday September 29, 2011 @09:44AM
(#3052387)
On this point I don't disagree, for this case you'd expect the data access layer to deal with all the database errors and return something useful to the request layer:
[ Parent
| on HN ]
Re:Fixing the callback spaghetti in node.js
by moe on Thursday September 29, 2011 @10:44AM
(#3052595)
you'd expect the data access layer to deal with all the database errors and return something useful
There you nailed the problem. It's a constant headache, especially since library authors have different ideas about the format and semantics of "something useful".
Before you know it you have re-invented your own half-baked exception-framework, to normalize/wrap/re-throw those ErrBacks. And then a week later you notice that rollback/retry and event cascades need a whole new level of treatment.
There's a reason why mature event-frameworks such as Twisted have never quite taken over the mainstream. It's sad to see node burn all its powder on a niche programming-style that just doesn't fly for the majority of applications.