From 712af489c3956765fb38446fe306c855f30217eb Mon Sep 17 00:00:00 2001 From: z Date: Mon, 25 Nov 2024 16:05:15 +0800 Subject: [PATCH] Adding error handling to embedWebFonts and embedImages --- src/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2de59a30..38c2e3b9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,8 +18,16 @@ export async function toSvg( ): Promise { const { width, height } = getImageSize(node, options) const clonedNode = (await cloneNode(node, options, true)) as HTMLElement - await embedWebFonts(clonedNode, options) - await embedImages(clonedNode, options) + try { + await embedWebFonts(clonedNode, options); + } catch (error) { + console.log('[embedWebFonts error]', error); + } + try { + await embedImages(clonedNode, options); + } catch (error) { + console.log('[embedImages error]', error); + } applyStyle(clonedNode, options) const datauri = await nodeToDataURL(clonedNode, width, height) return datauri