Commit 5c4691e
committed
fix(error-logging): rollup errors weren't displaying id and codeframe
The code which modified the error message to have additional context about the module id
and code frame where the error originated was relying on the error's stack having never
been accessed prior to modifying the error's message. At some point, this no longer was
true for Rollup errors, and no context information was being displayed as a result other
than the stack trace within the rollup library that doesn't make it clear what or where
the problem is.
This PR changes the code that add's the id and code-frame context to the error message
to also modify the error's stack. To do so, it attempts to extract the original stack
trace by removing the existing error message from error.stack if it matches, and
otherwise falls back to just displaying the stack trace with its own message since it
varies from the error.message.
Some additional normalization was done to the error.frame field if it exists to ensure
that consistent padding is used in the error output. This is because the rollup code-
frame doesn't have new-lines around it, but the esbuild one does.
Fixes #165391 parent 6c323d5 commit 5c4691e
1 file changed
Lines changed: 44 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
544 | 574 | | |
| 575 | + | |
| 576 | + | |
545 | 577 | | |
546 | 578 | | |
547 | 579 | | |
548 | 580 | | |
549 | 581 | | |
550 | 582 | | |
551 | 583 | | |
552 | | - | |
| 584 | + | |
553 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
554 | 597 | | |
555 | 598 | | |
556 | 599 | | |
| |||
0 commit comments