File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @file Unit Tests - ERR_ILLEGAL_CONSTRUCTOR
3
+ * @module errnode/models/tests/unit/ERR_ILLEGAL_CONSTRUCTOR
4
+ */
5
+
6
+ import { ErrorCode } from '#src/enums'
7
+ import type { NodeError } from '#src/types'
8
+ import TestSubject from '../err-illegal-constructor'
9
+
10
+ describe ( 'unit:models/ERR_ILLEGAL_CONSTRUCTOR' , ( ) => {
11
+ let result : NodeError < TypeError >
12
+
13
+ beforeEach ( ( ) => {
14
+ result = new TestSubject ( )
15
+ } )
16
+
17
+ it ( 'should return TypeError instance' , ( ) => {
18
+ expect ( result ) . to . have . property ( 'name' ) . equal ( 'TypeError' )
19
+ expect ( result ) . to . be . instanceof ( TypeError )
20
+ } )
21
+
22
+ it ( 'should set error code' , ( ) => {
23
+ expect ( result )
24
+ . to . have . property ( 'code' )
25
+ . equal ( ErrorCode . ERR_ILLEGAL_CONSTRUCTOR )
26
+ } )
27
+
28
+ it ( 'should set error message' , ( ) => {
29
+ expect ( result ) . to . have . property ( 'message' ) . equal ( 'Illegal constructor' )
30
+ } )
31
+ } )
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @file Error Models - ERR_ILLEGAL_CONSTRUCTOR
3
+ * @module errnode/models/ERR_ILLEGAL_CONSTRUCTOR
4
+ * @see https://github.com/nodejs/node/blob/v19.3.0/lib/internal/errors.js#L1163
5
+ */
6
+
7
+ import { ErrorCode } from '#src/enums'
8
+ import type { NodeError , NodeErrorConstructor } from '#src/types'
9
+ import { createNodeError } from '#src/utils'
10
+
11
+ /**
12
+ * `ERR_ILLEGAL_CONSTRUCTOR` model.
13
+ *
14
+ * Thrown when an attempt is made to construct an object using a non-public
15
+ * constructor.
16
+ *
17
+ * @see https://nodejs.org/api/errors.html#err_illegal_constructor
18
+ *
19
+ * @class
20
+ *
21
+ * @return {NodeError<TypeError> } `TypeError` instance
22
+ */
23
+ const ERR_ILLEGAL_CONSTRUCTOR : NodeErrorConstructor < TypeErrorConstructor , [ ] > =
24
+ createNodeError (
25
+ ErrorCode . ERR_ILLEGAL_CONSTRUCTOR ,
26
+ TypeError ,
27
+ 'Illegal constructor'
28
+ )
29
+
30
+ export default ERR_ILLEGAL_CONSTRUCTOR
Original file line number Diff line number Diff line change 7
7
export { default as ERR_AMBIGUOUS_ARGUMENT } from './err-ambiguous-argument'
8
8
export { default as ERR_ARG_NOT_ITERABLE } from './err-arg-not-iterable'
9
9
export { default as ERR_ASYNC_CALLBACK } from './err-async-callback'
10
+ export { default as ERR_ILLEGAL_CONSTRUCTOR } from './err-illegal-constructor'
You can’t perform that action at this time.
0 commit comments