console: check that stderr is writable
authorRich Trott <rtrott@gmail.com>
Wed, 9 Mar 2016 23:26:34 +0000 (15:26 -0800)
committerMyles Borins <mborins@us.ibm.com>
Wed, 30 Mar 2016 20:12:14 +0000 (13:12 -0700)
commit0c6f6742f250f10a0e47a1f0c69a50abcd9b28ac
tree989afcb9d4b9a0f93d1cbb64942f053f44f8e976
parent1d0e4a987d42bf16c9ac4dc3dd8ce57f08f7fdd1
console: check that stderr is writable

`Console` constructor checks that `stdout.write()` is a function but
does not do an equivalent check for `stderr.write()`. If `stderr` is not
specified in the constructor, then `stderr` is set to be `stdout`.
However, if `stderr` is specified, but `stderr.write()` is not a
function, then an exception is not thrown until `console.error()` is
called.

This change adds the same check for 'stderr' in the constructor that is
there for `stdout`. If `stderr` fails the check, then a `TypeError` is
thrown.

Took the opportunity to copyedit the `console` doc a little too.

PR-URL: https://github.com/nodejs/node/pull/5635
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
doc/api/console.markdown
lib/console.js
test/parallel/test-console-instance.js