errors: migrate lib/console

Migrate console.js to use internal/errors.js.

PR-URL: https://github.com/nodejs/node/pull/11340
Ref: https://github.com/nodejs/node/issues/11273
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
This commit is contained in:
mskec authored and Franziska Hinkelmann committed 2017-05-27 09:28:07 +02:00
1 parent ae5e65c72f
commit 0ecdf29340
4 files changed
+32 -10

No files matched your search

+20 -8
View File
@@ -37,16 +37,28 @@ assert.strictEqual('function', typeof Console);
// make sure that the Console constructor throws
// when not given a writable stream instance
assert.throws(() => {
new Console();
}, /^TypeError: Console expects a writable stream instance$/);
assert.throws(
() => { new Console(); },
common.expectsError({
code: 'ERR_CONSOLE_WRITABLE_STREAM',
type: TypeError,
message: /stdout/
})
);
// Console constructor should throw if stderr exists but is not writable
assert.throws(() => {
out.write = common.noop;
err.write = undefined;
new Console(out, err);
}, /^TypeError: Console expects writable stream instances$/);
assert.throws(
() => {
out.write = common.noop;
err.write = undefined;
new Console(out, err);
},
common.expectsError({
code: 'ERR_CONSOLE_WRITABLE_STREAM',
type: TypeError,
message: /stderr/
})
);
out.write = err.write = (d) => {};