|
| 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 | +} |
0 commit comments