Skip to content

Commit

Permalink
Preserve all error stack lines (#4364)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Aug 18, 2022
1 parent 41b81d0 commit 77b0680
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-comics-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Preserve all error stack lines
1 change: 0 additions & 1 deletion packages/astro/src/core/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export interface ErrorWithMetadata {
export function cleanErrorStack(stack: string) {
return stack
.split(/\n/g)
.filter((l) => /^\s*at/.test(l))
.map((l) => l.replace(/\/@fs\//g, '/'))
.join('\n');
}
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/core/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { AddressInfo } from 'net';
import os from 'os';
import { ZodError } from 'zod';
import type { AstroConfig } from '../@types/astro';
import { cleanErrorStack, ErrorWithMetadata } from './errors.js';
import { ErrorWithMetadata } from './errors.js';
import { emoji, getLocalAddress, padMultilineString } from './util.js';

const PREFIX_PADDING = 6;
Expand Down Expand Up @@ -235,10 +235,10 @@ export function formatErrorMessage(err: ErrorWithMetadata, args: string[] = []):
args.push(red(padMultilineString(err.frame, 4)));
}
if (args.length === 1 && err.stack) {
args.push(dim(cleanErrorStack(err.stack)));
args.push(dim(err.stack));
} else if (err.stack) {
args.push(` ${bold('Stacktrace:')}`);
args.push(dim(cleanErrorStack(err.stack)));
args.push(dim(err.stack));
args.push(``);
}
return args.join('\n');
Expand Down

0 comments on commit 77b0680

Please sign in to comment.