Skip to content

Commit

Permalink
Merge pull request #39 from mash-up-kr/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
seohyun0120 authored Aug 3, 2024
2 parents 27b8012 + 28029d3 commit ecc4087
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/controller/keyword.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ const getTopKeywords = async (req: Request, res: Response, next: NextFunction) =
const topReactionImage: string = await MemeService.getTopReactionImage(keyword);
return { ...keyword, topReactionImage } as IKeywordWithImage;
} catch (error) {
logger.error(`Error retrieving top reaction image for keyword: ${keyword}`, error);
logger.error(
`Error retrieving top reaction image for keyword: ${JSON.stringify(keyword._id)}`,
error,
);
throw new CustomError(`Failed to get top reaction image`, HttpCode.INTERNAL_SERVER_ERROR);
}
},
Expand Down
6 changes: 5 additions & 1 deletion src/service/meme.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,14 @@ async function getTopReactionImage(keyword: IKeywordDocument): Promise<string> {
reaction: -1,
});

if (_.isNull(topReactionMeme)) {
throw new CustomError(`Failed get top reaction meme image`, HttpCode.NOT_FOUND);
}

logger.info(`Get top reaction meme - keyword(${keyword.name}), meme(${topReactionMeme._id})`);
return topReactionMeme.image;
} catch (err) {
logger.error(`Failed get top reaction meme`, err.message);
logger.error(`Failed get top reaction meme image`, err.message);
throw new CustomError(
`Failed get top reaction meme(${err.message})`,
HttpCode.INTERNAL_SERVER_ERROR,
Expand Down

0 comments on commit ecc4087

Please sign in to comment.