Skip to content

Commit

Permalink
Log a warning when image search env variables are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Mar 16, 2024
1 parent ea987c1 commit a2af6e8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/app/image-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a2af6e8

Please sign in to comment.