Skip to content
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

Improving the error message in building process #8404

Closed
1 task
roberto-butti opened this issue Aug 30, 2023 · 3 comments · Fixed by #8405
Closed
1 task

Improving the error message in building process #8404

roberto-butti opened this issue Aug 30, 2023 · 3 comments · Fixed by #8405
Labels
- P2: nice to have Not breaking anything but nice to have (priority)

Comments

@roberto-butti
Copy link

What version of starlight are you using?

0.8.0

What is your idea?

I'm playing with this tool, and that is great!
Improving the error message output during the build phase would be nice.
For example, if the mdx file contains some invalid character, I see a clear error message:

 error   Unexpected character `/` (U+002F) before local name, expected a character that can start a name, such as a letter, `$`, or `_` (note: to create a link in MDX, use `[text](url)`)
  File:
    /Users/roberto/visible-binary/src/content/docs/book/000_intro.mdx

or for example

[@mdx-js/rollup] Unexpected character `,` (U+002C) before name, expected a character that can start a name, such as a letter, `$`, or `_`
file: /Users/roberto/visible-binary/src/content/docs/book/009_sys_version_compare.mdx

The message is clear and shows the name of the file.
It would be nice (if possible) to have the number of the line of the file that raised the exception.

Why is this feature necessary?

To identify in a quick way the error to fix

Do you have examples of this feature in other projects?

No response

Participation

  • I am willing to submit a pull request for this issue.
@delucis
Copy link
Member

delucis commented Sep 2, 2023

Thanks for the issue @roberto-butti! I believe those two errors are thrown by the MDX compiler itself, but would be good to investigate if they provide line numbers that Astro doesn't surface for some reason or if this would be something MDX needs to add to their error reporting.

@delucis
Copy link
Member

delucis commented Sep 4, 2023

Just played around with https://mdxjs.com/playground/ and badly formatted code does seem to report line and column data alongside the error. Will ask the Astro team if there’s a way to show that same data in Astro’s errors for MDX content.

@delucis
Copy link
Member

delucis commented Sep 4, 2023

Confirmed we can improve this in Astro. Will transfer this issue across and fix it upstream.

@delucis delucis transferred this issue from withastro/starlight Sep 4, 2023
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Sep 4, 2023
@delucis delucis added - P2: nice to have Not breaking anything but nice to have (priority) needs triage Issue needs to be triaged and removed needs triage Issue needs to be triaged labels Sep 4, 2023
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants