On Sat, Apr 21, 2012 at 06:11:08AM -0700, P. Douglas Reeder wrote:
> In addition to dealing with this directly, make sure you have an
> uncaught exception handler:
> 
> process.on('uncaughtException', function (err) {
>       console.error("caught by event loop: ", err.stack);
> });

Don't do that. When this event fires, you should clean up everything that needs 
to be cleaned up and exit. Just printing the error and going on is not a good 
idea because your program might be in an inconsistent state. For example, look 
at this piece of code:

    user.firstname = uppercaseFirst(options.firstname)
    user.lastname = uppercaseFirst(options.lastname)

However, options.lastname unfortunately is null for some weird reason and 
uppercaseFirst crashes. Now, this users first name was changed but his last 
name is unaltered. You don't want to go on working with data like that.

Attachment: pgpqJRWbZdbQu.pgp
Description: PGP signature

Reply via email to