Skip to content

Commit

Permalink
Add error handling for MDX content rendering in chat text component
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Feb 18, 2025
1 parent 5f93328 commit 1859d66
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/xgen/components/chat/text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ const Index = (props: IProps) => {
if (!compiledSource) return
// compiledSource.value = (compiledSource.value as string).replaceAll('%7B', '{')

const { default: Content } = await run(compiledSource, {
...JsxRuntime,
Fragment,
useMDXComponents: () => mdxComponents
})

setContent(Content)
try {
const { default: Content } = await run(compiledSource, {
...JsxRuntime,
Fragment,
useMDXComponents: () => mdxComponents
})
setContent(Content)
} catch (err) {
console.error(err)
console.log(`original text:\n`, text)
}
}, [text])

return <div className={styles._local}>{content}</div>
Expand Down

0 comments on commit 1859d66

Please sign in to comment.