From ffd1c898d66289f72e7a1a87f948dfc24baf9ac0 Mon Sep 17 00:00:00 2001 From: HgO Date: Wed, 27 Jul 2022 21:35:30 +0200 Subject: [PATCH] handle invalid duration and silence expired exceptions --- matrix_alertbot/command.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/matrix_alertbot/command.py b/matrix_alertbot/command.py index 33acf96..3c3b88f 100644 --- a/matrix_alertbot/command.py +++ b/matrix_alertbot/command.py @@ -11,6 +11,8 @@ from matrix_alertbot.config import Config from matrix_alertbot.errors import ( AlertmanagerError, AlertNotFoundError, + InvalidDurationError, + SilenceExpiredError, SilenceNotFoundError, ) @@ -136,7 +138,7 @@ class AckAlertCommand(BaseAlertCommand): duration_seconds, cached_silence_id, ) - except AlertNotFoundError as e: + except (AlertNotFoundError, InvalidDurationError) as e: logger.warning(f"Unable to create silence: {e}") await send_text_to_room( self.client, @@ -200,7 +202,7 @@ class UnackAlertCommand(BaseAlertCommand): try: await self.alertmanager.delete_silence(silence_id) - except (AlertNotFoundError, SilenceNotFoundError) as e: + except (SilenceNotFoundError, SilenceExpiredError) as e: logger.error(f"Unable to delete silence: {e}") await send_text_to_room( self.client,