mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
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:
parent
0deb27bd29
commit
109cfa1511
4 changed files with 45 additions and 56 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue