mariocasciaro / scatter

IoC container and out-of-the-box extensibility for Node.js applications
MIT License
154 stars 14 forks source link

How can I find the uncaught exceptions when loading particle? #32

Closed zhangpp520 closed 9 years ago

zhangpp520 commented 9 years ago

Sometimes,I make mistakes,something like forget to install modules.So,When I start the app,it just hangs there. If I don't use Scatter,I will see the error stacks in the console.

Why dosen't Scatter just throw the exceptions?or Can I see the errors in the console?

mariocasciaro commented 9 years ago

Try to provide a log function to the Scatter constructor, this will give you a fine grained logging of what's happening in the Scatter internals. Scatter uses promises, so you can catch any exception and log it:

scatter.load('your_initial_component')
.then(function(say) {
  say.doSay();
})
.catch(function(err) {
  console.log(err)
})
zhangpp520 commented 9 years ago

Thanks!