{"record":{"id":"8237f5fe9a3bfd07","repo":"toeverything/AFFiNE","slug":"mobile-preview-handler-string-name-is-unavai","errorCode":null,"errorMessage":"Mobile preview handler \"${String(name)}\" is unavailable.","messagePattern":"Mobile preview handler \"(.+?)\" is unavailable\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/modules/code-block-preview-renderer/platform-backend.mobile.ts","lineNumber":9,"sourceCode":"import { getNativePreviewHandlers } from './runtime-config';\nimport type { PreviewRenderRequestMap, PreviewRenderResultMap } from './types';\n\nfunction getRequiredNativeHandler<\n  Name extends keyof NonNullable<ReturnType<typeof getNativePreviewHandlers>>,\n>(name: Name) {\n  const handler = getNativePreviewHandlers()?.[name];\n  if (!handler) {\n    throw new Error(`Mobile preview handler \"${String(name)}\" is unavailable.`);\n  }\n  return handler;\n}\n\nexport async function renderMermaidSvgBackend(\n  request: PreviewRenderRequestMap['mermaid']\n): Promise<PreviewRenderResultMap['mermaid']> {\n  return getRequiredNativeHandler('renderMermaidSvg')(request);\n}\n\nexport async function renderTypstSvgBackend(\n  request: PreviewRenderRequestMap['typst']\n): Promise<PreviewRenderResultMap['typst']> {\n  return getRequiredNativeHandler('renderTypstSvg')(request);\n}\n","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/modules/code-block-preview-renderer/platform-backend.mobile.ts#L1-L25","documentation":"getRequiredNativeHandler throws when the native (mobile) runtime provides no preview handlers or lacks the requested handler, meaning the mobile bridge cannot render this preview type (mermaid/typst).","triggerScenarios":"Thrown when a mobile code block preview render (mermaid or typst) is requested but the native preview handler returned by getNativePreviewHandlers is absent.","commonSituations":"Occurs on the mobile app when native preview capabilities are not registered or unavailable; verify the native runtime config provides the preview handlers before rendering code block previews.","solutions":["Register the mobile preview handler before requesting a preview.","Use a supported preview type on mobile."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}