Skip to content

Commit db87bd6

Browse files
committed
feat(errors): ERR_IMPORT_ATTRIBUTE_UNSUPPORTED
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent c6305f8 commit db87bd6

File tree

7 files changed

+128
-0
lines changed

7 files changed

+128
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ This package exports the following identifiers:
149149
- `ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED`
150150
- `ERR_IMPORT_ATTRIBUTE_MISSING`
151151
- `ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE`
152+
- `ERR_IMPORT_ATTRIBUTE_UNSUPPORTED`
152153
- `ERR_INCOMPATIBLE_OPTION_PAIR`
153154
- `ERR_INVALID_ARG_TYPE`
154155
- `ERR_INVALID_ARG_VALUE`

src/__snapshots__/errors.integration.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ exports[`integration:errors > ERR_IMPORT_ATTRIBUTE_MISSING > #toString > should
1212

1313
exports[`integration:errors > ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE > #toString > should return string representation of error 1`] = `TypeError [ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE]: Module "data:text/javascript,export{}" is not of type "json"`;
1414

15+
exports[`integration:errors > ERR_IMPORT_ATTRIBUTE_UNSUPPORTED > #toString > should return string representation of error 1`] = `TypeError [ERR_IMPORT_ATTRIBUTE_UNSUPPORTED]: Import attribute "type" with value "unsupported" is not supported`;
16+
1517
exports[`integration:errors > ERR_INCOMPATIBLE_OPTION_PAIR > #toString > should return string representation of error 1`] = `TypeError [ERR_INCOMPATIBLE_OPTION_PAIR]: Option 'N' cannot be used in combination with option 'cost'`;
1618

1719
exports[`integration:errors > ERR_INVALID_ARG_TYPE > #toString > should return string representation of error 1`] = `TypeError [ERR_INVALID_ARG_TYPE]: The 'ctor' argument must be of type function. Received null`;

src/__snapshots__/index.e2e.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports[`e2e:errnode > should expose public api 1`] = `
1111
"ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED",
1212
"ERR_IMPORT_ATTRIBUTE_MISSING",
1313
"ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE",
14+
"ERR_IMPORT_ATTRIBUTE_UNSUPPORTED",
1415
"ERR_INCOMPATIBLE_OPTION_PAIR",
1516
"ERR_INVALID_ARG_TYPE",
1617
"ERR_INVALID_ARG_VALUE",

src/__tests__/errors.integration.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('integration:errors', () => {
4848
JS_MODULE_DATA_URL,
4949
'json'
5050
],
51+
[codes.ERR_IMPORT_ATTRIBUTE_UNSUPPORTED, TypeError, 'type', 'unsupported'],
5152
[codes.ERR_INCOMPATIBLE_OPTION_PAIR, TypeError, 'N', 'cost'],
5253
[codes.ERR_INVALID_ARG_TYPE, TypeError, 'ctor', 'Function', null],
5354
[codes.ERR_INVALID_ARG_VALUE, TypeError, 'address', 1],
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @file Type Tests - ERR_IMPORT_ATTRIBUTE_UNSUPPORTED
3+
* @module errnode/errors/tests/unit-d/ERR_IMPORT_ATTRIBUTE_UNSUPPORTED
4+
*/
5+
6+
import { codes } from '#src/enums'
7+
import type { NodeError, NodeErrorConstructor } from '#src/interfaces'
8+
import type * as TestSubject from '../err-import-attribute-unsupported'
9+
10+
describe('unit-d:errors/ERR_IMPORT_ATTRIBUTE_UNSUPPORTED', () => {
11+
describe('ERR_IMPORT_ATTRIBUTE_UNSUPPORTED', () => {
12+
it('should be ErrImportAttributeUnsupportedConstructor', () => {
13+
expectTypeOf<typeof TestSubject.default>()
14+
.toEqualTypeOf<TestSubject.ErrImportAttributeUnsupportedConstructor>()
15+
})
16+
})
17+
18+
describe('ErrImportAttributeUnsupported', () => {
19+
it('should extend NodeError<codes.ERR_IMPORT_ATTRIBUTE_UNSUPPORTED>', () => {
20+
expectTypeOf<TestSubject.ErrImportAttributeUnsupported>()
21+
.toMatchTypeOf<NodeError<codes.ERR_IMPORT_ATTRIBUTE_UNSUPPORTED>>()
22+
})
23+
24+
it('should extend TypeError', () => {
25+
expectTypeOf<TestSubject.ErrImportAttributeUnsupported>()
26+
.toMatchTypeOf<TypeError>()
27+
})
28+
})
29+
30+
describe('ErrImportAttributeUnsupportedConstructor', () => {
31+
it('should match NodeErrorConstructor', () => {
32+
// Arrange
33+
type T = TestSubject.ErrImportAttributeUnsupported
34+
type Args = TestSubject.ErrImportAttributeUnsupportedArgs
35+
36+
// Expect
37+
expectTypeOf<TestSubject.ErrImportAttributeUnsupportedConstructor>()
38+
.toMatchTypeOf<NodeErrorConstructor<T, Args>>()
39+
})
40+
})
41+
})
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* @file Errors - ERR_IMPORT_ATTRIBUTE_UNSUPPORTED
3+
* @module errnode/errors/ERR_IMPORT_ATTRIBUTE_UNSUPPORTED
4+
* @see https://github.com/nodejs/node/blob/v22.7.0/lib/internal/errors.js#L1344-L1345
5+
*/
6+
7+
import E from '#e'
8+
import { codes } from '#src/enums'
9+
import type { NodeError, NodeErrorConstructor } from '#src/interfaces'
10+
11+
/**
12+
* `ERR_IMPORT_ATTRIBUTE_UNSUPPORTED` schema.
13+
*
14+
* @see {@linkcode NodeError}
15+
* @see https://nodejs.org/api/errors.html#err_import_attribute_unsupported
16+
*
17+
* @extends {NodeError<codes.ERR_IMPORT_ATTRIBUTE_UNSUPPORTED>}
18+
* @extends {TypeError}
19+
*/
20+
interface ErrImportAttributeUnsupported
21+
extends NodeError<codes.ERR_IMPORT_ATTRIBUTE_UNSUPPORTED>, TypeError {}
22+
23+
/**
24+
* `ERR_IMPORT_ATTRIBUTE_UNSUPPORTED` message arguments.
25+
*/
26+
type Args = [key: string, value: string]
27+
28+
/**
29+
* `ERR_IMPORT_ATTRIBUTE_UNSUPPORTED` constructor.
30+
*
31+
* @see {@linkcode Args}
32+
* @see {@linkcode ErrImportAttributeUnsupported}
33+
* @see {@linkcode NodeErrorConstructor}
34+
*
35+
* @extends {NodeErrorConstructor<ErrImportAttributeUnsupported,Args>}
36+
*/
37+
interface ErrImportAttributeUnsupportedConstructor
38+
extends NodeErrorConstructor<ErrImportAttributeUnsupported, Args> {
39+
/**
40+
* Create a new `ERR_IMPORT_ATTRIBUTE_UNSUPPORTED` error.
41+
*
42+
* @see {@linkcode ErrImportAttributeUnsupported}
43+
*
44+
* @param {string} key
45+
* Import attribute key
46+
* @param {string} value
47+
* Import attribute value
48+
* @return {ErrImportAttributeUnsupported}
49+
*/
50+
new (key: string, value: string): ErrImportAttributeUnsupported
51+
}
52+
53+
/**
54+
* `ERR_IMPORT_ATTRIBUTE_UNSUPPORTED` model.
55+
*
56+
* Thrown when an import attribute is not supported by a version of Node.js.
57+
*
58+
* @see {@linkcode ErrImportAttributeUnsupportedConstructor}
59+
*
60+
* @type {ErrImportAttributeUnsupportedConstructor}
61+
*
62+
* @class
63+
*/
64+
const ERR_IMPORT_ATTRIBUTE_UNSUPPORTED:
65+
ErrImportAttributeUnsupportedConstructor = E(
66+
codes.ERR_IMPORT_ATTRIBUTE_UNSUPPORTED,
67+
TypeError,
68+
'Import attribute "%s" with value "%s" is not supported'
69+
)
70+
71+
export {
72+
ERR_IMPORT_ATTRIBUTE_UNSUPPORTED as default,
73+
type ErrImportAttributeUnsupported,
74+
type Args as ErrImportAttributeUnsupportedArgs,
75+
type ErrImportAttributeUnsupportedConstructor
76+
}

src/errors/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export {
4040
type ErrImportAttributeTypeIncompatibleArgs,
4141
type ErrImportAttributeTypeIncompatibleConstructor
4242
} from './err-import-attribute-type-incompatible'
43+
export {
44+
default as ERR_IMPORT_ATTRIBUTE_UNSUPPORTED,
45+
type ErrImportAttributeUnsupported,
46+
type ErrImportAttributeUnsupportedArgs,
47+
type ErrImportAttributeUnsupportedConstructor
48+
} from './err-import-attribute-unsupported'
4349
export {
4450
default as ERR_INCOMPATIBLE_OPTION_PAIR,
4551
type ErrIncompatibleOptionPair,

0 commit comments

Comments
 (0)