(Base, key)
| 432 | } |
| 433 | |
| 434 | function makeNodeErrorWithCode(Base, key) { |
| 435 | const msg = messages.get(key); |
| 436 | const expectedLength = typeof msg !== 'string' ? -1 : getExpectedArgumentLength(msg); |
| 437 | |
| 438 | switch (expectedLength) { |
| 439 | case 0: { |
| 440 | class NodeError extends Base { |
| 441 | code = key; |
| 442 | |
| 443 | constructor(...args) { |
| 444 | assert( |
| 445 | args.length === 0, |
| 446 | `Code: ${key}; The provided arguments length (${args.length}) does not ` + |
| 447 | `match the required ones (${expectedLength}).`, |
| 448 | ); |
| 449 | super(msg); |
| 450 | } |
| 451 | |
| 452 | // This is a workaround for wpt tests that expect that the error |
| 453 | // constructor has a `name` property of the base class. |
| 454 | get ['constructor']() { |
| 455 | return Base; |
| 456 | } |
| 457 | |
| 458 | get [kIsNodeError]() { |
| 459 | return true; |
| 460 | } |
| 461 | |
| 462 | toString() { |
| 463 | return `${this.name} [${key}]: ${this.message}`; |
| 464 | } |
| 465 | } |
| 466 | return NodeError; |
| 467 | } |
| 468 | case -1: { |
| 469 | class NodeError extends Base { |
| 470 | code = key; |
| 471 | |
| 472 | constructor(...args) { |
| 473 | super(); |
| 474 | ObjectDefineProperty(this, 'message', { |
| 475 | __proto__: null, |
| 476 | value: getMessage(key, args, this), |
| 477 | enumerable: false, |
| 478 | writable: true, |
| 479 | configurable: true, |
| 480 | }); |
| 481 | } |
| 482 | |
| 483 | // This is a workaround for wpt tests that expect that the error |
| 484 | // constructor has a `name` property of the base class. |
| 485 | get ['constructor']() { |
| 486 | return Base; |
| 487 | } |
| 488 | |
| 489 | get [kIsNodeError]() { |
| 490 | return true; |
| 491 | } |
no test coverage detected
searching dependent graphs…