-
-
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
Conversation
@@ -232,7 +234,7 @@ async function syncContentCollections( | |||
{ | |||
...AstroErrorData.GenerateContentTypesError, | |||
hint, | |||
message: AstroErrorData.GenerateContentTypesError.message(safeError.message), | |||
message: AstroErrorData.GenerateContentTypesError.message(`${safeError.message} in ${fileId}`), |
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.
instead of using the file id in the message, you could pass it under loc
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.
Sure, I will do that.
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.
removed fileId and added location
Co-authored-by: Emanuele Stoppa <[email protected]>
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.
await sync({ flags }); | ||
return; |
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.
if (showFullStacktrace && err.loc) { | ||
output.push(` ${bold('Location:')}`); | ||
output.push(` ${underline(`${err.loc.file}:${err.loc.line ?? 0}:${err.loc.column ?? 0}`)}`); | ||
} |
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.
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.
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.
Love to see less try catches around
Changes
-
astro build
does not report which file has an invalid frontmatter for MDX files.This PR fixes that.
After the fix, the error looks like the below:
Closes #12352
Testing
It was manually tested by running a local build.
Docs
Not needed as it just enhances existing error messages.