|
| 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