DOCXKIT_EXPORT_FAILED: 文档导出失败
编译后的文档打包失败,调用方仍可读取原始 cause。
修复步骤
- 在本地检查 error.cause,定位失败资源。
- 使用当前平台支持的导出格式,并确认引用资源有效。
问题示例
ts
// Packaging can fail when a referenced resource is invalid.
// Inspect the original cause at the export boundary.修复示例
ts
import { createDocx, DocxKitError, serializeDocxKitError } from 'docx-kit'
try {
const blob = await createDocx().p('Hello').toBlob()
} catch (error) {
if (error instanceof DocxKitError) {
console.error(serializeDocxKitError(error))
// Inspect error.cause locally when needed.
} else {
throw error
}
}常见原因
- 文档资源无效,或底层打包过程失败。
诊断字段
code:EXPORT_FAILEDdiagnosticCode:DOCXKIT_EXPORT_FAILEDname:DocxKitErrordocs: https://docx-kit.ntnyq.dev/errors/docxkit_export_failed/
消息示例
text
Failed to pack document to blob