From 9cecdd17eb81d7585c8a0ab86645bc31856d8dc3 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:31:08 +1000 Subject: [PATCH] feat(uI): improved error handling when getting composite canvas images Wrap logic that might throw in a result and handle log it if it errors before throwing. --- .../controlLayers/konva/CanvasCompositorModule.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasCompositorModule.ts b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasCompositorModule.ts index c52d9c179c..3508530d80 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasCompositorModule.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasCompositorModule.ts @@ -277,13 +277,19 @@ export class CanvasCompositorModule extends CanvasModuleBase { this.log.warn({ rect, imageName: cachedImageName }, 'Cached image name not found, recompositing'); } - const canvas = this.getCompositeCanvas(adapters, rect, compositingOptions); + const getCompositeCanvasResult = withResult(() => this.getCompositeCanvas(adapters, rect, compositingOptions)); + + if (getCompositeCanvasResult.isErr()) { + this.log.error({ error: serializeError(getCompositeCanvasResult.error) }, 'Failed to get composite canvas'); + throw getCompositeCanvasResult.error; + } this.$isProcessing.set(true); - const blobResult = await withResultAsync(() => canvasToBlob(canvas)); + const blobResult = await withResultAsync(() => canvasToBlob(getCompositeCanvasResult.value)); this.$isProcessing.set(false); if (blobResult.isErr()) { + this.log.error({ error: serializeError(blobResult.error) }, 'Failed to convert composite canvas to blob'); throw blobResult.error; } const blob = blobResult.value;