fix: handle render errors (#3557)

This commit is contained in:
David Luzar 2021-05-09 21:43:36 +02:00 committed by GitHub
parent 91ab7f36e2
commit 6bebfe63be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 16 deletions

View File

@ -206,7 +206,7 @@ const drawElementOnCanvas = (
context.canvas.remove(); context.canvas.remove();
} }
} else { } else {
console.error(`Unimplemented type ${element.type}`); throw new Error(`Unimplemented type ${element.type}`);
} }
} }
} }

View File

@ -269,7 +269,11 @@ export const renderScene = (
); );
visibleElements.forEach((element) => { visibleElements.forEach((element) => {
try {
renderElement(element, rc, context, renderOptimizations, sceneState); renderElement(element, rc, context, renderOptimizations, sceneState);
} catch (error) {
console.error(error);
}
}); });
if (appState.editingLinearElement) { if (appState.editingLinearElement) {
@ -283,6 +287,7 @@ export const renderScene = (
// Paint selection element // Paint selection element
if (selectionElement) { if (selectionElement) {
try {
renderElement( renderElement(
selectionElement, selectionElement,
rc, rc,
@ -290,6 +295,9 @@ export const renderScene = (
renderOptimizations, renderOptimizations,
sceneState, sceneState,
); );
} catch (error) {
console.error(error);
}
} }
if (isBindingEnabled(appState)) { if (isBindingEnabled(appState)) {
@ -834,6 +842,7 @@ export const renderSceneToSvg = (
// render elements // render elements
elements.forEach((element) => { elements.forEach((element) => {
if (!element.isDeleted) { if (!element.isDeleted) {
try {
renderElementToSvg( renderElementToSvg(
element, element,
rsvg, rsvg,
@ -841,6 +850,9 @@ export const renderSceneToSvg = (
element.x + offsetX, element.x + offsetX,
element.y + offsetY, element.y + offsetY,
); );
} catch (error) {
console.error(error);
}
} }
}); });
}; };