Skip to content

Commit 632c79a

Browse files
committed
feat(errors): ERR_INVALID_FILE_URL_HOST
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 84330ce commit 632c79a

File tree

7 files changed

+128
-0
lines changed

7 files changed

+128
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ This package exports the following identifiers:
143143
- [`codes`](#codes)
144144
- [`determineSpecificType`](#determinespecifictypevalue)
145145
- [`errors`](#errors)
146+
- `ERR_ARG_NOT_ITERABLE`
146147
- `ERR_ENCODING_NOT_SUPPORTED`
147148
- `ERR_IMPORT_ASSERTION_TYPE_FAILED`
148149
- `ERR_IMPORT_ASSERTION_TYPE_MISSING`
@@ -153,6 +154,7 @@ This package exports the following identifiers:
153154
- `ERR_INCOMPATIBLE_OPTION_PAIR`
154155
- `ERR_INVALID_ARG_TYPE`
155156
- `ERR_INVALID_ARG_VALUE`
157+
- `ERR_INVALID_FILE_URL_HOST`
156158
- `ERR_INVALID_MODULE_SPECIFIER`
157159
- `ERR_INVALID_PACKAGE_CONFIG`
158160
- `ERR_INVALID_PACKAGE_TARGET`

src/__snapshots__/errors.integration.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ exports[`integration:errors > ERR_INVALID_ARG_TYPE > #toString > should return s
2222

2323
exports[`integration:errors > ERR_INVALID_ARG_VALUE > #toString > should return string representation of error 1`] = `TypeError [ERR_INVALID_ARG_VALUE]: The argument 'address' is invalid. Received 1`;
2424

25+
exports[`integration:errors > ERR_INVALID_FILE_URL_HOST > #toString > should return string representation of error 1`] = `TypeError [ERR_INVALID_FILE_URL_HOST]: File URL host must be "localhost" or empty on darwin`;
26+
2527
exports[`integration:errors > ERR_INVALID_MODULE_SPECIFIER > #toString > should return string representation of error 1`] = `TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module '@flex-development%2Fpathe' is not a valid package name imported from \${process.cwd()}/scratch.ts`;
2628

2729
exports[`integration:errors > ERR_INVALID_PACKAGE_CONFIG > #toString > should return string representation of error 1`] = `Error [ERR_INVALID_PACKAGE_CONFIG]: Invalid package config \${process.cwd()}/node_modules/@flex-development/pathe/package.json while importing file://\${process.cwd()}/loader.mjs. "exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`;

src/__snapshots__/index.e2e.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ exports[`e2e:errnode > should expose public api 1`] = `
1616
"ERR_INCOMPATIBLE_OPTION_PAIR",
1717
"ERR_INVALID_ARG_TYPE",
1818
"ERR_INVALID_ARG_VALUE",
19+
"ERR_INVALID_FILE_URL_HOST",
1920
"ERR_INVALID_MODULE_SPECIFIER",
2021
"ERR_INVALID_PACKAGE_CONFIG",
2122
"ERR_INVALID_PACKAGE_TARGET",

src/__tests__/errors.integration.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ describe('integration:errors', () => {
5353
[codes.ERR_INCOMPATIBLE_OPTION_PAIR, TypeError, 'N', 'cost'],
5454
[codes.ERR_INVALID_ARG_TYPE, TypeError, 'ctor', 'Function', null],
5555
[codes.ERR_INVALID_ARG_VALUE, TypeError, 'address', 1],
56+
[codes.ERR_INVALID_FILE_URL_HOST, TypeError, 'darwin'],
5657
[
5758
codes.ERR_INVALID_MODULE_SPECIFIER,
5859
TypeError,
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @file Type Tests - ERR_INVALID_FILE_URL_HOST
3+
* @module errnode/errors/tests/unit-d/ERR_INVALID_FILE_URL_HOST
4+
*/
5+
6+
import { codes } from '#src/enums'
7+
import type { NodeError, NodeErrorConstructor } from '#src/interfaces'
8+
import type * as TestSubject from '../err-invalid-file-url-host'
9+
10+
describe('unit-d:errors/ERR_INVALID_FILE_URL_HOST', () => {
11+
describe('ERR_INVALID_FILE_URL_HOST', () => {
12+
it('should be ErrInvalidFileUrlHostConstructor', () => {
13+
expectTypeOf<typeof TestSubject.default>()
14+
.toEqualTypeOf<TestSubject.ErrInvalidFileUrlHostConstructor>()
15+
})
16+
})
17+
18+
describe('ErrInvalidFileUrlHost', () => {
19+
it('should extend NodeError<codes.ERR_INVALID_FILE_URL_HOST>', () => {
20+
expectTypeOf<TestSubject.ErrInvalidFileUrlHost>()
21+
.toMatchTypeOf<NodeError<codes.ERR_INVALID_FILE_URL_HOST>>()
22+
})
23+
24+
it('should extend TypeError', () => {
25+
expectTypeOf<TestSubject.ErrInvalidFileUrlHost>()
26+
.toMatchTypeOf<TypeError>()
27+
})
28+
})
29+
30+
describe('ErrInvalidFileUrlHostConstructor', () => {
31+
it('should match NodeErrorConstructor', () => {
32+
// Arrange
33+
type T = TestSubject.ErrInvalidFileUrlHost
34+
type Args = TestSubject.ErrInvalidFileUrlHostArgs
35+
36+
// Expect
37+
expectTypeOf<TestSubject.ErrInvalidFileUrlHostConstructor>()
38+
.toMatchTypeOf<NodeErrorConstructor<T, Args>>()
39+
})
40+
})
41+
})
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* @file Errors - ERR_INVALID_FILE_URL_HOST
3+
* @module errnode/errors/ERR_INVALID_FILE_URL_HOST
4+
* @see https://github.com/nodejs/node/blob/v22.8.0/lib/internal/errors.js#L1470-L1471
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_INVALID_FILE_URL_HOST` schema.
13+
*
14+
* @see {@linkcode NodeError}
15+
* @see https://nodejs.org/api/errors.html#err_invalid_file_url_host
16+
*
17+
* @extends {NodeError<codes.ERR_INVALID_FILE_URL_HOST>}
18+
* @extends {TypeError}
19+
*/
20+
interface ErrInvalidFileUrlHost
21+
extends NodeError<codes.ERR_INVALID_FILE_URL_HOST>, TypeError {}
22+
23+
/**
24+
* `ERR_INVALID_FILE_URL_HOST` message arguments.
25+
*/
26+
type Args = [platform: string]
27+
28+
/**
29+
* `ERR_INVALID_FILE_URL_HOST` constructor.
30+
*
31+
* @see {@linkcode ErrInvalidFileUrlHost}
32+
* @see {@linkcode NodeErrorConstructor}
33+
*
34+
* @extends {NodeErrorConstructor<ErrInvalidFileUrlHost,Args>}
35+
*/
36+
interface ErrInvalidFileUrlHostConstructor
37+
extends NodeErrorConstructor<ErrInvalidFileUrlHost, Args> {
38+
/**
39+
* Create a new `ERR_INVALID_FILE_URL_HOST` error.
40+
*
41+
* @see {@linkcode ErrInvalidFileUrlHost}
42+
*
43+
* @param {string} platform
44+
* Platform invalid host was encountered on
45+
* @return {ErrInvalidFileUrlHost}
46+
*/
47+
new (platform: string): ErrInvalidFileUrlHost
48+
}
49+
50+
/**
51+
* `ERR_INVALID_FILE_URL_HOST` model.
52+
*
53+
* Thrown when a Node.js API that consumes `file:` URLs encountered a file URL
54+
* with an incompatible host.
55+
* This situation can only occur on Unix-like systems where only `localhost` or
56+
* an empty host is supported.
57+
*
58+
* @see {@linkcode ErrInvalidFileUrlHostConstructor}
59+
*
60+
* @type {ErrInvalidFileUrlHostConstructor}
61+
*
62+
* @class
63+
*/
64+
const ERR_INVALID_FILE_URL_HOST: ErrInvalidFileUrlHostConstructor = E(
65+
codes.ERR_INVALID_FILE_URL_HOST,
66+
TypeError,
67+
'File URL host must be "localhost" or empty on %s'
68+
)
69+
70+
export {
71+
ERR_INVALID_FILE_URL_HOST as default,
72+
type ErrInvalidFileUrlHost,
73+
type Args as ErrInvalidFileUrlHostArgs,
74+
type ErrInvalidFileUrlHostConstructor
75+
}

src/errors/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ export {
7070
type ErrInvalidArgValueArgs,
7171
type ErrInvalidArgValueConstructor
7272
} from './err-invalid-arg-value'
73+
export {
74+
default as ERR_INVALID_FILE_URL_HOST,
75+
type ErrInvalidFileUrlHost,
76+
type ErrInvalidFileUrlHostArgs,
77+
type ErrInvalidFileUrlHostConstructor
78+
} from './err-invalid-file-url-host'
7379
export {
7480
default as ERR_INVALID_MODULE_SPECIFIER,
7581
type ErrInvalidModuleSpecifier,

0 commit comments

Comments
 (0)