From a45db101c861eb198706804351a1966c66d49e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Tue, 24 Oct 2023 16:32:36 +0800 Subject: [PATCH] :art: Add Exception Handler in Damage Analysis --- plugins/genshin/player_cards.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/genshin/player_cards.py b/plugins/genshin/player_cards.py index 3cbd6ec3..6374ed68 100644 --- a/plugins/genshin/player_cards.py +++ b/plugins/genshin/player_cards.py @@ -42,6 +42,7 @@ from utils.uid import mask_number try: from python_genshin_artifact.calculator import get_damage_analysis, get_transformative_damage from python_genshin_artifact.enka.enka_parser import enka_parser + from python_genshin_artifact.error import JsonParseException, EnkaParseException from python_genshin_artifact.models.calculator import CalculatorConfig from python_genshin_artifact.models.skill import SkillInfo @@ -577,8 +578,14 @@ class RenderTemplate: character_cn_name = idToName(self.character.id) damage_config = self.damage_config.get(character_cn_name) if damage_config is not None: - data["damage_function_available"] = True - data["damage_info"] = self.render_damage(damage_config) + try: + data["damage_info"] = self.render_damage(damage_config) + except JsonParseException as _exc: + logger.error(str(_exc)) + except EnkaParseException as _exc: + logger.error(str(_exc)) + else: + data["damage_function_available"] = True return await self.template_service.render( "genshin/player_card/player_card.jinja2",