(e: RollupError)
| 922 | } |
| 923 | |
| 924 | export function enhanceRollupError(e: RollupError): void { |
| 925 | const stackOnly = extractStack(e) |
| 926 | |
| 927 | let msg = colors.red((e.plugin ? `[${e.plugin}] ` : '') + e.message) |
| 928 | if (e.loc && e.loc.file && e.loc.file !== e.id) { |
| 929 | msg += `\nfile: ${colors.cyan( |
| 930 | `${e.loc.file}:${e.loc.line}:${e.loc.column}` + |
| 931 | (e.id ? ` (${e.id})` : ''), |
| 932 | )}` |
| 933 | } else if (e.id) { |
| 934 | msg += `\nfile: ${colors.cyan( |
| 935 | e.id + (e.loc ? `:${e.loc.line}:${e.loc.column}` : ''), |
| 936 | )}` |
| 937 | } |
| 938 | if (e.frame) { |
| 939 | msg += `\n` + colors.yellow(normalizeCodeFrame(e.frame)) |
| 940 | } |
| 941 | |
| 942 | e.message = msg |
| 943 | |
| 944 | // We are rebuilding the stack trace to include the more detailed message at the top. |
| 945 | // Previously this code was relying on mutating e.message changing the generated stack |
| 946 | // when it was accessed, but we don't have any guarantees that the error we are working |
| 947 | // with hasn't already had its stack accessed before we get here. |
| 948 | if (stackOnly !== undefined) { |
| 949 | e.stack = `${e.message}\n${stackOnly}` |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | /** |
| 954 | * The stack string usually contains a copy of the message at the start of the stack. |
no test coverage detected