handle invalid duration and silence expired exceptions
This commit is contained in:
parent
978f0adc61
commit
ffd1c898d6
1 changed files with 4 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue