you can throw anything in js, even an empty string. (a good way to break a test framework)
would this work? stderr.on('drain', function () { process.exit(1) }) console.error('fail') On Mon, Jul 16, 2012 at 6:18 AM, Alan Gutierrez <a...@prettyrobots.com> wrote: > I'm writing command line utilities in Node.js. Here's a snippet that is > a source of some concern for me. > > try { > options = require('arguable')(__filename); > } catch (error) { > console.error('error: ' + e.message); > console.error(e.usage); > process.exit(1); > } > > frobinate(options.severity); > > Essentially, I'm calling an options parser and finding errors that > prevent me form continuing. I want to exit with a non-zero exit code. > > However, if I exit abruptly, I find that the console is not always > flushed. Sometimes on Windows. Sometimes when piping stderr. > > I'm wondering when I can count on a flush of stderr before exit, when I > can't, and what you feel is the right way to exit from a command line > program, if you have any thoughts on the matter. > > Currently, I'm creating a main function, surrounding that in a try/catch > block, and throwing special exceptions to indicate that the error does > not involve a stack trace. > > -- > Alan Gutierrez - http://github.com/bigeasy - http://twitter.com/bigeasy > > -- > 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 -- 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