-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: show file name with invalid frontmatter errors for MDX #12355
Changes from all commits
05dd8b5
0c8e746
50d177f
c839742
a3c8e20
44b85e4
6f93247
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Improves error reporting for invalid frontmatter in MDX files during the `astro build` command. The error message now includes the file path where the frontmatter parsing failed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,6 +298,11 @@ export function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: b | |
output.push(` ${cyan(underline(docsLink))}`); | ||
} | ||
|
||
if (showFullStacktrace && err.loc) { | ||
output.push(` ${bold('Location:')}`); | ||
output.push(` ${underline(`${err.loc.file}:${err.loc.line ?? 0}:${err.loc.column ?? 0}`)}`); | ||
} | ||
Comment on lines
+301
to
+304
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was something removed by Fred's previous pass on errors making them shorter 😃 I added it back, but only when the full stack trace is shown (which is either in debug in dev, or on full crashes in the CLI), so it should be shown in only contexts where it's not available elsewhere. |
||
|
||
if (err.stack) { | ||
output.push(` ${bold('Stack trace:')}`); | ||
output.push(dim(formatErrorStackTrace(err, showFullStacktrace))); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a global handler for CLI that handles more stuff (telemetry, error formatting etc) so this wasn't really useful.