From 07b5e113bf5cf44908af0b6a8df3e2978c8bffd9 Mon Sep 17 00:00:00 2001 From: Jayant Bhawal Date: Wed, 13 Dec 2023 02:22:00 +0530 Subject: [PATCH] Fix: If a single image gen breaks, that should not break the whole thing --- src/api-helpers/image-gen.ts | 4 ++-- src/api-helpers/vercel-generator.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api-helpers/image-gen.ts b/src/api-helpers/image-gen.ts index a29f507..d424cab 100644 --- a/src/api-helpers/image-gen.ts +++ b/src/api-helpers/image-gen.ts @@ -25,11 +25,11 @@ export const generateImages = async ( createImageUsingVercel( { ...adaptedData[cardName], username: data.user.login }, cardName - ) + ).catch(() => null) ) ); - return imageFileBuffers; + return imageFileBuffers.filter(Boolean) as ImageFile[]; } catch (error) { console.error('Error in generateImages:', error); logException('Error in generateImages', { originalException: error }); diff --git a/src/api-helpers/vercel-generator.tsx b/src/api-helpers/vercel-generator.tsx index 8a6686e..f98b573 100644 --- a/src/api-helpers/vercel-generator.tsx +++ b/src/api-helpers/vercel-generator.tsx @@ -42,7 +42,7 @@ export const createImageUsingVercel = async ( try { imageArrayBuffer = await generatedImage.arrayBuffer(); } catch (error) { - logException('Error converting image to array buffer for ${cardType}', { + logException(`Error converting image to array buffer for ${cardType}`, { originalException: error }); throw new Error(`Image buffer creation failed for ${cardType}`);