defendtheweb / NexBot

Node.js IRC bot
Other
8 stars 8 forks source link

[Stability] Update main.js #46

Closed Pawda closed 10 years ago

Pawda commented 10 years ago

Add a global catch on unexpected exception so the server keep running.

verath commented 10 years ago

I like the thought behind it, but the documentation is quite clear on that it shouldn't be used http://nodejs.org/api/process.html#process_event_uncaughtexception.

It would imo be preferable if someone were to make sure we caught all possible exceptions where they might occur instead. The application is rather small, and I can't think there are too many places left where exceptions could be thrown. Adding a try catch around the calls to module.handle and module.join might also be enough?

Then again, this might be a good temporary solution. Up to flabby to decide, I'm sure he'll like your pull requests either way :).

Pawda commented 10 years ago

My bad, I'm discovering nodejs so I wasn't aware it was a bad practice. Anyway, you're right whatever the language a big try-catch should be avoided and it was made to be a temporary solution ;).