Skip to content

Commit 8c4a555

Browse files
committed
feat(errors): ERR_NO_ICU
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent eb50fa9 commit 8c4a555

File tree

11 files changed

+128
-8
lines changed

11 files changed

+128
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ This package exports the following identifiers:
170170
- `ERR_MODULE_NOT_FOUND`
171171
- `ERR_NETWORK_IMPORT_DISALLOWED`
172172
- `ERR_NO_CRYPTO`
173+
- `ERR_NO_ICU`
173174
- `ERR_OPERATION_FAILED`
174175
- `ERR_PACKAGE_IMPORT_NOT_DEFINED`
175176
- `ERR_PACKAGE_PATH_NOT_EXPORTED`

src/__snapshots__/errors.integration.snap

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

5555
exports[`integration:errors > ERR_NO_CRYPTO > #toString > should return string representation of error 1`] = `Error [ERR_NO_CRYPTO]: Node.js is not compiled with OpenSSL crypto support`;
5656

57+
exports[`integration:errors > ERR_NO_ICU > #toString > should return string representation of error 1`] = `TypeError [ERR_NO_ICU]: "fatal" option is not supported on Node.js compiled without ICU`;
58+
5759
exports[`integration:errors > ERR_OPERATION_FAILED > #toString > should return string representation of error 1`] = `Error [ERR_OPERATION_FAILED]: Operation failed: Out of memory`;
5860

5961
exports[`integration:errors > ERR_PACKAGE_IMPORT_NOT_DEFINED > #toString > should return string representation of error 1`] = `TypeError [ERR_PACKAGE_IMPORT_NOT_DEFINED]: Package import specifier '#src' is not defined in package \${process.cwd()}/package.json imported from file://\${process.cwd()}/src/__tests__/errors.integration.spec.ts`;

src/__snapshots__/index.e2e.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ exports[`e2e:errnode > should expose public api 1`] = `
3232
"ERR_MODULE_NOT_FOUND",
3333
"ERR_NETWORK_IMPORT_DISALLOWED",
3434
"ERR_NO_CRYPTO",
35+
"ERR_NO_ICU",
3536
"ERR_OPERATION_FAILED",
3637
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
3738
"ERR_PACKAGE_PATH_NOT_EXPORTED",

src/__tests__/errors.integration.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ describe('integration:errors', () => {
105105
'ES modules cannot be loaded by require() from the network'
106106
],
107107
[codes.ERR_NO_CRYPTO, Error],
108+
[codes.ERR_NO_ICU, TypeError, '"fatal" option'],
108109
[codes.ERR_OPERATION_FAILED, Error, 'Out of memory'],
109110
[
110111
codes.ERR_PACKAGE_IMPORT_NOT_DEFINED,

src/errors/__tests__/err-invalid-this.spec-d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ describe('unit-d:errors/ERR_INVALID_THIS', () => {
2222
})
2323

2424
it('should extend TypeError', () => {
25-
expectTypeOf<TestSubject.ErrInvalidThis>()
26-
.toMatchTypeOf<TypeError>()
25+
expectTypeOf<TestSubject.ErrInvalidThis>().toMatchTypeOf<TypeError>()
2726
})
2827
})
2928

src/errors/__tests__/err-invalid-tuple.spec-d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ describe('unit-d:errors/ERR_INVALID_TUPLE', () => {
2222
})
2323

2424
it('should extend TypeError', () => {
25-
expectTypeOf<TestSubject.ErrInvalidTuple>()
26-
.toMatchTypeOf<TypeError>()
25+
expectTypeOf<TestSubject.ErrInvalidTuple>().toMatchTypeOf<TypeError>()
2726
})
2827
})
2928

src/errors/__tests__/err-invalid-url.spec-d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ describe('unit-d:errors/ERR_INVALID_URL', () => {
2323
})
2424

2525
it('should extend TypeError', () => {
26-
expectTypeOf<TestSubject.ErrInvalidUrl>()
27-
.toMatchTypeOf<TypeError>()
26+
expectTypeOf<TestSubject.ErrInvalidUrl>().toMatchTypeOf<TypeError>()
2827
})
2928

3029
it('should match [base?: URL | string | null | undefined]', () => {

src/errors/__tests__/err-missing-args.spec-d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ describe('unit-d:errors/ERR_MISSING_ARGS', () => {
2222
})
2323

2424
it('should extend TypeError', () => {
25-
expectTypeOf<TestSubject.ErrMissingArgs>()
26-
.toMatchTypeOf<TypeError>()
25+
expectTypeOf<TestSubject.ErrMissingArgs>().toMatchTypeOf<TypeError>()
2726
})
2827
})
2928

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @file Type Tests - ERR_NO_ICU
3+
* @module errnode/errors/tests/unit-d/ERR_NO_ICU
4+
*/
5+
6+
import { codes } from '#src/enums'
7+
import type { NodeError, NodeErrorConstructor } from '#src/interfaces'
8+
import type * as TestSubject from '../err-no-icu'
9+
10+
describe('unit-d:errors/ERR_NO_ICU', () => {
11+
describe('ERR_NO_ICU', () => {
12+
it('should be ErrNoIcuConstructor', () => {
13+
expectTypeOf<typeof TestSubject.default>()
14+
.toEqualTypeOf<TestSubject.ErrNoIcuConstructor>()
15+
})
16+
})
17+
18+
describe('ErrNoIcu', () => {
19+
it('should extend NodeError<codes.ERR_NO_ICU>', () => {
20+
expectTypeOf<TestSubject.ErrNoIcu>()
21+
.toMatchTypeOf<NodeError<codes.ERR_NO_ICU>>()
22+
})
23+
24+
it('should extend TypeError', () => {
25+
expectTypeOf<TestSubject.ErrNoIcu>().toMatchTypeOf<TypeError>()
26+
})
27+
})
28+
29+
describe('ErrNoIcuConstructor', () => {
30+
it('should match NodeErrorConstructor', () => {
31+
// Arrange
32+
type T = TestSubject.ErrNoIcu
33+
type Args = TestSubject.ErrNoIcuArgs
34+
35+
// Expect
36+
expectTypeOf<TestSubject.ErrNoIcuConstructor>()
37+
.toMatchTypeOf<NodeErrorConstructor<T, Args>>()
38+
})
39+
})
40+
})

src/errors/err-no-icu.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* @file Errors - ERR_NO_ICU
3+
* @module errnode/errors/ERR_NO_ICU
4+
* @see https://github.com/nodejs/node/blob/v22.8.0/lib/internal/errors.js#L1605-L1606
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_NO_ICU` schema.
13+
*
14+
* @see {@linkcode NodeError}
15+
* @see https://nodejs.org/api/errors.html#err_no_icu
16+
*
17+
* @extends {NodeError<codes.ERR_NO_ICU>}
18+
* @extends {TypeError}
19+
*/
20+
interface ErrNoIcu extends NodeError<codes.ERR_NO_ICU>, TypeError {}
21+
22+
/**
23+
* `ERR_NO_ICU` message arguments.
24+
*/
25+
type Args = [feature: string]
26+
27+
/**
28+
* `ERR_NO_ICU` constructor.
29+
*
30+
* @see {@linkcode ErrNoIcu}
31+
* @see {@linkcode NodeErrorConstructor}
32+
*
33+
* @extends {NodeErrorConstructor<ErrNoIcu,Args>}
34+
*/
35+
interface ErrNoIcuConstructor extends NodeErrorConstructor<ErrNoIcu, Args> {
36+
/**
37+
* Create a new `ERR_NO_ICU` error.
38+
*
39+
* @see {@linkcode ErrNoIcu}
40+
*
41+
* @param {string} feature
42+
* Description of feature that requires ICU
43+
* @return {ErrNoIcu}
44+
*/
45+
new (feature: string): ErrNoIcu
46+
}
47+
48+
/**
49+
* `ERR_NO_ICU` model.
50+
*
51+
* Thrown when an attempt was made to use features that require [ICU][icu], but
52+
* Node.js was not compiled with ICU support.
53+
*
54+
* [icu]: https://nodejs.org/api/intl.html#internationalization-support
55+
*
56+
* @see {@linkcode ErrNoIcuConstructor}
57+
*
58+
* @type {ErrNoIcuConstructor}
59+
*
60+
* @class
61+
*/
62+
const ERR_NO_ICU: ErrNoIcuConstructor = E(
63+
codes.ERR_NO_ICU,
64+
TypeError,
65+
'%s is not supported on Node.js compiled without ICU'
66+
)
67+
68+
export {
69+
ERR_NO_ICU as default,
70+
type ErrNoIcu,
71+
type Args as ErrNoIcuArgs,
72+
type ErrNoIcuConstructor
73+
}

0 commit comments

Comments
 (0)