lib: tweak use of internal/errors

In addition refactor common.throws to common.expectsError

PR-URL: https://github.com/nodejs/node/pull/13829
Refs: https://github.com/nodejs/node/issues/11273
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Ruben Bridgewater 2017-06-20 23:20:10 +02:00 committed by Refael Ackermann
parent 8979b4fc9f
commit 095357e26e
No known key found for this signature in database
GPG key ID: CD704BD80FDDDB64
6 changed files with 49 additions and 53 deletions

View file

@ -1,17 +1,11 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const encoding = 'foo-8';
const filename = 'bar.txt';
const expectedError = common.expectsError({
code: 'ERR_INVALID_OPT_VALUE_ENCODING',
type: TypeError,
});
assert.throws(
common.expectsError(
fs.readFile.bind(fs, filename, { encoding }, common.mustNotCall()),
expectedError
{ code: 'ERR_INVALID_OPT_VALUE_ENCODING', type: TypeError }
);