|
| 1 | +/** |
| 2 | + * @file Errors - ERR_INVALID_TUPLE |
| 3 | + * @module errnode/errors/ERR_INVALID_TUPLE |
| 4 | + * @see https://github.com/nodejs/node/blob/v22.8.0/lib/internal/errors.js#L1530 |
| 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_TUPLE` schema. |
| 13 | + * |
| 14 | + * @see {@linkcode NodeError} |
| 15 | + * @see https://nodejs.org/api/errors.html#err_invalid_tuple |
| 16 | + * |
| 17 | + * @extends {NodeError<codes.ERR_INVALID_TUPLE>} |
| 18 | + * @extends {TypeError} |
| 19 | + */ |
| 20 | +interface ErrInvalidTuple |
| 21 | + extends NodeError<codes.ERR_INVALID_TUPLE>, TypeError {} |
| 22 | + |
| 23 | +/** |
| 24 | + * `ERR_INVALID_TUPLE` message arguments. |
| 25 | + */ |
| 26 | +type Args = [description: string, tuple: string] |
| 27 | + |
| 28 | +/** |
| 29 | + * `ERR_INVALID_TUPLE` constructor. |
| 30 | + * |
| 31 | + * @see {@linkcode ErrInvalidTuple} |
| 32 | + * @see {@linkcode NodeErrorConstructor} |
| 33 | + * |
| 34 | + * @extends {NodeErrorConstructor<ErrInvalidTuple,Args>} |
| 35 | + */ |
| 36 | +interface ErrInvalidTupleConstructor |
| 37 | + extends NodeErrorConstructor<ErrInvalidTuple, Args> { |
| 38 | + /** |
| 39 | + * Create a new `ERR_INVALID_TUPLE` error. |
| 40 | + * |
| 41 | + * @see {@linkcode ErrInvalidTuple} |
| 42 | + * |
| 43 | + * @param {string} description |
| 44 | + * Description of required tuple |
| 45 | + * @param {string} tuple |
| 46 | + * String representation of tuple |
| 47 | + * @return {ErrInvalidTuple} |
| 48 | + */ |
| 49 | + new (description: string, tuple: string): ErrInvalidTuple |
| 50 | +} |
| 51 | + |
| 52 | +/** |
| 53 | + * `ERR_INVALID_TUPLE` model. |
| 54 | + * |
| 55 | + * Thrown when an element in the iterable provided to the [WHATWG][whatwg] |
| 56 | + * [`URLSearchParams` constructor][constructor] did not represent a |
| 57 | + * `[name, value]` tuple. |
| 58 | + * |
| 59 | + * [constructor]: https://nodejs.org/api/url.html#new-urlsearchparamsiterable |
| 60 | + * [whatwg]: https://nodejs.org/api/url.html#the-whatwg-url-api |
| 61 | + * |
| 62 | + * @see {@linkcode ErrInvalidTupleConstructor} |
| 63 | + * |
| 64 | + * @type {ErrInvalidTupleConstructor} |
| 65 | + * |
| 66 | + * @class |
| 67 | + */ |
| 68 | +const ERR_INVALID_TUPLE: ErrInvalidTupleConstructor = E( |
| 69 | + codes.ERR_INVALID_TUPLE, |
| 70 | + TypeError, |
| 71 | + '%s must be an iterable %s tuple' |
| 72 | +) |
| 73 | + |
| 74 | +export { |
| 75 | + ERR_INVALID_TUPLE as default, |
| 76 | + type ErrInvalidTuple, |
| 77 | + type Args as ErrInvalidTupleArgs, |
| 78 | + type ErrInvalidTupleConstructor |
| 79 | +} |
0 commit comments