question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to check if your content is going to throw an error?

See original GitHub issue

I’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:closed
  • Created a year ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
hahnbeeleecommented, Nov 3, 2022

I think we’re just going to try to migrate to mdx-bundler 🥲 Thank you for all of your help though!

1reaction
BRKalowcommented, Nov 26, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found