diff --git a/src/app/components/generator/PreviewPanel.tsx b/src/app/components/generator/PreviewPanel.tsx
index 90196e28..8a11b44e 100644
--- a/src/app/components/generator/PreviewPanel.tsx
+++ b/src/app/components/generator/PreviewPanel.tsx
@@ -1,25 +1,47 @@
import type { DocAndNode } from '@spyglassmc/core'
+import { useErrorBoundary } from 'preact/hooks'
import { useDocAndNode } from '../../contexts/Spyglass.jsx'
import { useVersion } from '../../contexts/Version.jsx'
import { checkVersion } from '../../services/index.js'
import { safeJsonParse } from '../../Utils.js'
+import { ErrorPanel } from '../ErrorPanel.jsx'
import { BiomeSourcePreview, BlockStatePreview, DecoratorPreview, DensityFunctionPreview, LootTablePreview, ModelPreview, NoisePreview, NoiseSettingsPreview, RecipePreview, StructureSetPreview } from '../previews/index.js'
export const HasPreview = ['loot_table', 'recipe', 'dimension', 'worldgen/density_function', 'worldgen/noise', 'worldgen/noise_settings', 'worldgen/configured_feature', 'worldgen/placed_feature', 'worldgen/structure_set', 'block_definition', 'docAndNode']
type PreviewPanelProps = {
- docAndNode: DocAndNode | undefined,
id: string,
+ docAndNode: DocAndNode | undefined,
shown: boolean,
- onError: (message: string) => unknown,
}
-export function PreviewPanel({ docAndNode: original, id, shown }: PreviewPanelProps) {
- const { version } = useVersion()
-
+export function PreviewPanel({ id, docAndNode: original, shown }: PreviewPanelProps) {
if (!original) return <>>
const docAndNode = useDocAndNode(original)
+ const [error, dismissError] = useErrorBoundary()
+
+ if (error) {
+ const previewError = new Error(`Preview error: ${error.message}`)
+ if (error.stack) {
+ previewError.stack = error.stack
+ }
+ return