Preserve all error stack lines (#4364)
This commit is contained in:
parent
41b81d0d7e
commit
77b068086d
3 changed files with 8 additions and 4 deletions
5
.changeset/rare-comics-roll.md
Normal file
5
.changeset/rare-comics-roll.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Preserve all error stack lines
|
|
@ -37,7 +37,6 @@ export interface ErrorWithMetadata {
|
||||||
export function cleanErrorStack(stack: string) {
|
export function cleanErrorStack(stack: string) {
|
||||||
return stack
|
return stack
|
||||||
.split(/\n/g)
|
.split(/\n/g)
|
||||||
.filter((l) => /^\s*at/.test(l))
|
|
||||||
.map((l) => l.replace(/\/@fs\//g, '/'))
|
.map((l) => l.replace(/\/@fs\//g, '/'))
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import type { AddressInfo } from 'net';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { ZodError } from 'zod';
|
import { ZodError } from 'zod';
|
||||||
import type { AstroConfig } from '../@types/astro';
|
import type { AstroConfig } from '../@types/astro';
|
||||||
import { cleanErrorStack, ErrorWithMetadata } from './errors.js';
|
import { ErrorWithMetadata } from './errors.js';
|
||||||
import { emoji, getLocalAddress, padMultilineString } from './util.js';
|
import { emoji, getLocalAddress, padMultilineString } from './util.js';
|
||||||
|
|
||||||
const PREFIX_PADDING = 6;
|
const PREFIX_PADDING = 6;
|
||||||
|
@ -235,10 +235,10 @@ export function formatErrorMessage(err: ErrorWithMetadata, args: string[] = []):
|
||||||
args.push(red(padMultilineString(err.frame, 4)));
|
args.push(red(padMultilineString(err.frame, 4)));
|
||||||
}
|
}
|
||||||
if (args.length === 1 && err.stack) {
|
if (args.length === 1 && err.stack) {
|
||||||
args.push(dim(cleanErrorStack(err.stack)));
|
args.push(dim(err.stack));
|
||||||
} else if (err.stack) {
|
} else if (err.stack) {
|
||||||
args.push(` ${bold('Stacktrace:')}`);
|
args.push(` ${bold('Stacktrace:')}`);
|
||||||
args.push(dim(cleanErrorStack(err.stack)));
|
args.push(dim(err.stack));
|
||||||
args.push(``);
|
args.push(``);
|
||||||
}
|
}
|
||||||
return args.join('\n');
|
return args.join('\n');
|
||||||
|
|
Loading…
Reference in a new issue