From 76b098da2088ef5d3206e1bbf8fbeaec04d9c325 Mon Sep 17 00:00:00 2001 From: David Vilela Date: Sat, 30 Nov 2024 09:35:07 +0100 Subject: [PATCH] fix: try except --- .../memeooorr_abci/behaviour_classes/base.py | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/dvilela/skills/memeooorr_abci/behaviour_classes/base.py b/packages/dvilela/skills/memeooorr_abci/behaviour_classes/base.py index 3d37874..d14632f 100644 --- a/packages/dvilela/skills/memeooorr_abci/behaviour_classes/base.py +++ b/packages/dvilela/skills/memeooorr_abci/behaviour_classes/base.py @@ -381,17 +381,24 @@ def get_meme_coins_from_subgraph(self) -> Generator[None, None, Optional[List]]: # Load the response response_json = json.loads(response.body) - meme_coins = [ - { - "token_address": t["id"], - "liquidity": int(t["liquidity"]), - "heart_count": int(t["heartCount"]), - "is_unleashed": t["isUnleashed"], - "timestamp": t["timestamp"], - } - for t in response_json["data"]["memeTokens"]["items"] - if t["chain"] == "base" # TODO: adapt to Celo - ] + + try: + meme_coins = [ + { + "token_address": t["id"], + "liquidity": int(t["liquidity"]), + "heart_count": int(t["heartCount"]), + "is_unleashed": t["isUnleashed"], + "timestamp": t["timestamp"], + } + for t in response_json["data"]["memeTokens"]["items"] + if t["chain"] == "base" # TODO: adapt to Celo + ] + except KeyError as e: + self.context.logger.error( + f"Error while pulling the memes from subgraph: {e}" + ) + return [] enriched_meme_coins = yield from self.get_extra_meme_info(meme_coins)