From c3896bd3ce9a22941cb53429c9a7201824119e3f Mon Sep 17 00:00:00 2001 From: Jules Dejaeghere Date: Sat, 3 May 2025 20:16:48 +0200 Subject: [PATCH] Better error handling --- irm_kmi_api/rain_graph.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/irm_kmi_api/rain_graph.py b/irm_kmi_api/rain_graph.py index 411ba04..4f76727 100644 --- a/irm_kmi_api/rain_graph.py +++ b/irm_kmi_api/rain_graph.py @@ -11,7 +11,7 @@ from svgwrite import Drawing from svgwrite.animate import Animate from svgwrite.container import FONT_TEMPLATE -from .api import IrmKmiApiClient +from .api import IrmKmiApiClient, IrmKmiApiError from .const import OPTION_STYLE_SATELLITE from .data import AnimationFrameData, RadarAnimationData from .resources import be_black, be_satellite, be_white, nl, roboto @@ -96,8 +96,11 @@ class RainGraph: self._dwg = copy.deepcopy(self._dwg_save) self.draw_current_fame_line() self.draw_description_text() - await clouds - self.insert_cloud_layer() + try: + await clouds + self.insert_cloud_layer() + except IrmKmiApiError as err: + _LOGGER.warning(f"Could not download clouds from API: {err}") await self.draw_location() self._dwg_animated = self._dwg return self.get_svg_string(still_image=False) @@ -112,8 +115,11 @@ class RainGraph: self._dwg = copy.deepcopy(self._dwg_save) self.draw_current_fame_line(idx) self.draw_description_text(idx) - await cloud - self.insert_cloud_layer(idx) + try: + await cloud + self.insert_cloud_layer(idx) + except IrmKmiApiError as err: + _LOGGER.warning(f"Could not download clouds from API: {err}") await self.draw_location() self._dwg_still = self._dwg return self.get_svg_string(still_image=True)