handle invalid duration and silence expired exceptions

This commit is contained in:
HgO 2022-07-27 21:35:30 +02:00
parent 978f0adc61
commit ffd1c898d6

View file

@ -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,