Coverage for custom_components/supernotify/exceptions.py: 100%
8 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-09-25 14:29 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-09-25 14:29 +0000
1"""Custom exceptions for the Supernotify integration."""
3from __future__ import annotations
5from homeassistant.exceptions import HomeAssistantError
7from . import DOMAIN
10class UncategorizedTargetError(HomeAssistantError):
11 """One or more targets on this notification could not be matched to any delivery.
13 Raised once, at the end of a notification's delivery, after every target that *could*
14 be categorized has already been sent - this only reports the ones that were dropped.
15 """
17 def __init__(self, delivered_count: int, uncategorized: dict[str, list[str]]) -> None:
18 targets = sorted({t for values in uncategorized.values() for t in values})
19 deliveries = sorted(uncategorized.keys())
20 super().__init__(
21 translation_domain=DOMAIN,
22 translation_key="uncategorized_target",
23 translation_placeholders={
24 "delivered_count": str(delivered_count),
25 "uncategorized_count": str(len(targets)),
26 "uncategorized_targets": ", ".join(targets),
27 "deliveries": ", ".join(deliveries),
28 },
29 )