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

fix(loader): JSON parse throwing if isn't valid #37

Merged
merged 3 commits into from
Dec 8, 2020
Merged

fix(loader): JSON parse throwing if isn't valid #37

merged 3 commits into from
Dec 8, 2020

Conversation

davesnx
Copy link
Contributor

@davesnx davesnx commented Dec 8, 2020

For some reason when I cloned nextra-docs meta.json files were considered "META" from my editor and I kept doing silly mistakes.

-- Not sure why the deploy failed, but I would assume it's because It's not on my vercel account?

@vercel
Copy link

vercel bot commented Dec 8, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/shuding/nextra/37uomuqnq
✅ Preview: Failed

[Deployment for b85a003 failed]

Comment on lines 25 to 32
let parsed
try {
parsed = JSON.parse(file)
} catch (err) {
throw Error(`Error parsing ${path}, make sure it's a valid JSON \n` + err)
}

return parsed
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Will this error thrown make the dev server recoverable? Like do I need to restart the dev server once I fix the JSON file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't make the examples working with the local version so I can't test it manually. But I would assume so, since if there's any throw in a webpack loader it's a node process and it would crash. I believe there's a way to "accumulate" those errors in the webpack plugin API somewhere.

It might be simpler to console.error thought.

Let me try to run examples locally.

@shuding
Copy link
Owner

shuding commented Dec 8, 2020

Yeah the deployment fails is because the core branch isn't something deployable, I'll fix it.

Co-authored-by: Shu Ding <g@shud.in>
@shuding
Copy link
Owner

shuding commented Dec 8, 2020

Thanks!

tatukoivisto pushed a commit to tatukoivisto/nextra that referenced this pull request Aug 20, 2023
fix(loader): JSON parse throwing if isn't valid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants