errors: minor (SystemError) refactoring

This removes the former default values and the spread arguments
usage. That was unnecessary and now it does only what is necessary.
The `message` function got renamed to `getMessage` to outline that
it is actually a function and a helper function was inlined into
the SystemError constructor as it was only used there.

PR-URL: https://github.com/nodejs/node/pull/20337
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Ruben Bridgewater 2018-04-26 19:12:47 +02:00
parent 0deb27bd29
commit 109cfa1511
No known key found for this signature in database
GPG key ID: F07496B3EB3C1762
4 changed files with 45 additions and 56 deletions

View file

@ -3,12 +3,10 @@
require('../common');
const assert = require('assert');
const errors = require('internal/errors');
const { E, SystemError } = errors;
const { E, SystemError, codes } = require('internal/errors');
assert.throws(
() => { throw new errors.SystemError(); },
() => { throw new SystemError(); },
{
name: 'TypeError',
message: 'Cannot read property \'match\' of undefined'
@ -16,7 +14,7 @@ assert.throws(
);
E('ERR_TEST', 'custom message', SystemError);
const { ERR_TEST } = errors.codes;
const { ERR_TEST } = codes;
{
const ctx = {