| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cff2aea commit 058e882
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,6 @@ const { | |||
| 10 | 10 | ObjectDefineProperty, | |
| 11 | 11 | Symbol, | |
| 12 | 12 | SymbolToStringTag, | |
| 13 | - TypeError, | ||
| 14 | 13 | } = primordials; | |
| 15 | 14 | ||
| 16 | 15 | const { | |
@@ -25,6 +24,7 @@ const { | |||
| 25 | 24 | const { inspect } = require('internal/util/inspect'); | |
| 26 | 25 | const { | |
| 27 | 26 | codes: { | |
| 27 | + ERR_ILLEGAL_CONSTRUCTOR, | ||
| 28 | 28 | ERR_INVALID_THIS, | |
| 29 | 29 | } | |
| 30 | 30 | } = require('internal/errors'); | |
@@ -49,8 +49,7 @@ function validateAbortSignal(obj) { | |||
| 49 | 49 | ||
| 50 | 50 | class AbortSignal extends EventTarget { | |
| 51 | 51 | constructor() { | |
| 52 | - // eslint-disable-next-line no-restricted-syntax | ||
| 53 | - throw new TypeError('Illegal constructor'); | ||
| 52 | + throw new ERR_ILLEGAL_CONSTRUCTOR(); | ||
| 54 | 53 | } | |
| 55 | 54 | ||
| 56 | 55 | get aborted() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,11 +34,11 @@ const { | |||
| 34 | 34 | codes: { | |
| 35 | 35 | ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS, | |
| 36 | 36 | ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE, | |
| 37 | + ERR_CRYPTO_INVALID_JWK, | ||
| 38 | + ERR_ILLEGAL_CONSTRUCTOR, | ||
| 37 | 39 | ERR_INVALID_ARG_TYPE, | |
| 38 | 40 | ERR_INVALID_ARG_VALUE, | |
| 39 | 41 | ERR_OUT_OF_RANGE, | |
| 40 | - ERR_OPERATION_FAILED, | ||
| 41 | - ERR_CRYPTO_INVALID_JWK, | ||
| 42 | 42 | } | |
| 43 | 43 | } = require('internal/errors'); | |
| 44 | 44 | ||
@@ -631,7 +631,7 @@ function isKeyObject(obj) { | |||
| 631 | 631 | // would be fantastic if we could find a way of making those interop. | |
| 632 | 632 | class CryptoKey extends JSTransferable { | |
| 633 | 633 | constructor() { | |
| 634 | - throw new ERR_OPERATION_FAILED('Illegal constructor'); | ||
| 634 | + throw new ERR_ILLEGAL_CONSTRUCTOR(); | ||
| 635 | 635 | } | |
| 636 | 636 | ||
| 637 | 637 | [kInspect](depth, options) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ const { | |||
| 7 | 7 | ObjectSetPrototypeOf, | |
| 8 | 8 | SafeMap, | |
| 9 | 9 | Symbol, | |
| 10 | - TypeError, | ||
| 11 | 10 | } = primordials; | |
| 12 | 11 | ||
| 13 | 12 | const { | |
@@ -22,6 +21,7 @@ const { inspect } = require('util'); | |||
| 22 | 21 | ||
| 23 | 22 | const { | |
| 24 | 23 | codes: { | |
| 24 | + ERR_ILLEGAL_CONSTRUCTOR, | ||
| 25 | 25 | ERR_INVALID_ARG_VALUE, | |
| 26 | 26 | ERR_INVALID_ARG_TYPE, | |
| 27 | 27 | ERR_OUT_OF_RANGE, | |
@@ -130,8 +130,7 @@ class Histogram extends JSTransferable { | |||
| 130 | 130 | ||
| 131 | 131 | class RecordableHistogram extends Histogram { | |
| 132 | 132 | constructor() { | |
| 133 | - // eslint-disable-next-line no-restricted-syntax | ||
| 134 | - throw new TypeError('illegal constructor'); | ||
| 133 | + throw new ERR_ILLEGAL_CONSTRUCTOR(); | ||
| 135 | 134 | } | |
| 136 | 135 | ||
| 137 | 136 | record(val) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,14 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const { | |
| 3 | 3 | Symbol, | |
| 4 | - TypeError, | ||
| 5 | 4 | } = primordials; | |
| 6 | 5 | ||
| 6 | + const { | ||
| 7 | + codes: { | ||
| 8 | + ERR_ILLEGAL_CONSTRUCTOR, | ||
| 9 | + } | ||
| 10 | + } = require('internal/errors'); | ||
| 11 | + | ||
| 7 | 12 | const { | |
| 8 | 13 | ELDHistogram: _ELDHistogram, | |
| 9 | 14 | } = internalBinding('performance'); | |
@@ -23,8 +28,7 @@ const kEnabled = Symbol('kEnabled'); | |||
| 23 | 28 | class ELDHistogram extends Histogram { | |
| 24 | 29 | constructor(i) { | |
| 25 | 30 | if (!(i instanceof _ELDHistogram)) { | |
| 26 | - // eslint-disable-next-line no-restricted-syntax | ||
| 27 | - throw new TypeError('illegal constructor'); | ||
| 31 | + throw new ERR_ILLEGAL_CONSTRUCTOR(); | ||
| 28 | 32 | } | |
| 29 | 33 | super(i); | |
| 30 | 34 | this[kEnabled] = false; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,9 +4,14 @@ const { | |||
| 4 | 4 | ObjectDefineProperty, | |
| 5 | 5 | ObjectDefineProperties, | |
| 6 | 6 | ObjectSetPrototypeOf, | |
| 7 | - TypeError, | ||
| 8 | 7 | } = primordials; | |
| 9 | 8 | ||
| 9 | + const { | ||
| 10 | + codes: { | ||
| 11 | + ERR_ILLEGAL_CONSTRUCTOR, | ||
| 12 | + } | ||
| 13 | + } = require('internal/errors'); | ||
| 14 | + | ||
| 10 | 15 | const { | |
| 11 | 16 | EventTarget, | |
| 12 | 17 | } = require('internal/event_target'); | |
@@ -35,8 +40,7 @@ const { | |||
| 35 | 40 | ||
| 36 | 41 | class Performance extends EventTarget { | |
| 37 | 42 | constructor() { | |
| 38 | - // eslint-disable-next-line no-restricted-syntax | ||
| 39 | - throw new TypeError('Illegal constructor'); | ||
| 43 | + throw new ERR_ILLEGAL_CONSTRUCTOR(); | ||
| 40 | 44 | } | |
| 41 | 45 | ||
| 42 | 46 | [kInspect](depth, options) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,9 +3,14 @@ | |||
| 3 | 3 | const { | |
| 4 | 4 | ObjectSetPrototypeOf, | |
| 5 | 5 | Symbol, | |
| 6 | - TypeError, | ||
| 7 | 6 | } = primordials; | |
| 8 | 7 | ||
| 8 | + const { | ||
| 9 | + codes: { | ||
| 10 | + ERR_ILLEGAL_CONSTRUCTOR, | ||
| 11 | + } | ||
| 12 | + } = require('internal/errors'); | ||
| 13 | + | ||
| 9 | 14 | const { | |
| 10 | 15 | customInspectSymbol: kInspect, | |
| 11 | 16 | } = require('internal/util'); | |
@@ -25,8 +30,7 @@ function isPerformanceEntry(obj) { | |||
| 25 | 30 | ||
| 26 | 31 | class PerformanceEntry { | |
| 27 | 32 | constructor() { | |
| 28 | - // eslint-disable-next-line no-restricted-syntax | ||
| 29 | - throw new TypeError('illegal constructor'); | ||
| 33 | + throw new ERR_ILLEGAL_CONSTRUCTOR(); | ||
| 30 | 34 | } | |
| 31 | 35 | ||
| 32 | 36 | get name() { return this[kName]; } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,10 +56,9 @@ const { ok, strictEqual, throws } = require('assert'); | |||
| 56 | 56 | { | |
| 57 | 57 | // Tests that AbortSignal is impossible to construct manually | |
| 58 | 58 | const ac = new AbortController(); | |
| 59 | - throws( | ||
| 60 | - () => new ac.signal.constructor(), | ||
| 61 | - /^TypeError: Illegal constructor$/ | ||
| 62 | - ); | ||
| 59 | + throws(() => new ac.signal.constructor(), { | ||
| 60 | + code: 'ERR_ILLEGAL_CONSTRUCTOR', | ||
| 61 | + }); | ||
| 63 | 62 | } | |
| 64 | 63 | { | |
| 65 | 64 | // Symbol.toStringTag | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,8 +78,5 @@ const { inspect } = require('util'); | |||
| 78 | 78 | { | |
| 79 | 79 | // Tests that RecordableHistogram is impossible to construct manually | |
| 80 | 80 | const h = createHistogram(); | |
| 81 | - assert.throws( | ||
| 82 | - () => new h.constructor(), | ||
| 83 | - /^TypeError: illegal constructor$/ | ||
| 84 | - ); | ||
| 81 | + assert.throws(() => new h.constructor(), { code: 'ERR_ILLEGAL_CONSTRUCTOR' }); | ||
| 85 | 82 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -657,9 +657,7 @@ const vectors = { | |||
| 657 | 657 | })().then(common.mustCall()); | |
| 658 | 658 | ||
| 659 | 659 | // End user code cannot create CryptoKey directly | |
| 660 | - assert.throws(() => new CryptoKey(), { | ||
| 661 | - code: 'ERR_OPERATION_FAILED' | ||
| 662 | - }); | ||
| 660 | + assert.throws(() => new CryptoKey(), { code: 'ERR_ILLEGAL_CONSTRUCTOR' }); | ||
| 663 | 661 | ||
| 664 | 662 | { | |
| 665 | 663 | const buffer = Buffer.from('Hello World'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments