Is there a way to check if your content is going to throw an error?
See original GitHub issueI’m building an application using next-mdx-remote that has users who will write up custom content/pages. It isn’t guaranteed that the content is always going to be correct/compile. This is what I’m doing right now:
export default function Page({ stringifiedMdxSource }: PageProps) {
  const mdxSource = JSON.parse(stringifiedMdxSource);
  return <MDXRemote components={components} {...mdxSource} />
}
Is there a way for me to check if the content will compile? I don’t want my entire application to break due to one person uploading one incorrect file. I want it to silently fail. Thank you!
Issue Analytics
- State:
 - Created a year ago
 - Comments:12 (5 by maintainers)
 
Top Results From Across the Web
How to test the type of a thrown exception in Jest
I'm working with some code where I need to test the type of an exception thrown by a function (is it TypeError, ReferenceError,...
Read more >throw - JavaScript - MDN Web Docs - Mozilla
The throw statement throws a user-defined exception. ... If no catch block exists among caller functions, the program will terminate.
Read more >A Definitive Guide to Handling Errors in JavaScript - Kinsta
Getting tripped up by errors in your JavaScript? We'll show you how to tame those errors so you can get back to developing...
Read more >Error handling, "try...catch" - The Modern JavaScript Tutorial
When an error occurs, JavaScript generates an object containing the details about it. The object is then passed as an argument to catch...
Read more >Error Messages | Maps JavaScript API - Google Developers
To open the Developer Tools, select the menu icon > More Tools > Developer Tools. To open the JavaScript Console, press the ESC...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think we’re just going to try to migrate to mdx-bundler 🥲 Thank you for all of your help though!
Thanks for the update! Yeah we’ve run into this a bit as well, you can either try and detect it to escape the values, or remove it like you mentioned. It’s tough when authors aren’t aware of all of the differences between MD and MDX.