From a2af6e8e4f06bce57b4f8788896263034b5c1b4c Mon Sep 17 00:00:00 2001 From: Hendrik Liebau Date: Sat, 16 Mar 2024 13:28:01 +0100 Subject: [PATCH] Log a warning when image search env variables are missing --- src/app/image-set.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/image-set.ts b/src/app/image-set.ts index 2b147ed..35d5530 100644 --- a/src/app/image-set.ts +++ b/src/app/image-set.ts @@ -21,12 +21,18 @@ export function createImageSet(options: CreateImageSetOptions): ImageSet { JSON.stringify(searchResult.error), ); - return {status: `error` as const, title, errorMessage}; + if (searchResult.error.code === 400) { + console.warn( + `The env variables GOOGLE_SEARCH_API_KEY and GOOGLE_SEARCH_SEARCH_ENGINE_ID must be provided.`, + ); + } + + return {status: `error`, title, errorMessage}; } return searchResult.length === 0 - ? {status: `not-found` as const, title, notFoundMessage} - : {status: `found` as const, images: searchResult, title}; + ? {status: `not-found`, title, notFoundMessage} + : {status: `found`, images: searchResult, title}; } export function serializeImageSets(imageSets: ImageSet[]): string {