From 86f8cd80379f6c2b2f59a2963786d80151d22257 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 26 Feb 2021 18:33:13 -0600 Subject: [PATCH] Provide a human readable exception for the percentage util (#47121) --- homeassistant/util/percentage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/util/percentage.py b/homeassistant/util/percentage.py index 10a72a85dff..949af7dbb32 100644 --- a/homeassistant/util/percentage.py +++ b/homeassistant/util/percentage.py @@ -19,7 +19,7 @@ def ordered_list_item_to_percentage(ordered_list: List[str], item: str) -> int: """ if item not in ordered_list: - raise ValueError + raise ValueError(f'The item "{item}"" is not in "{ordered_list}"') list_len = len(ordered_list) list_position = ordered_list.index(item) + 1 @@ -42,7 +42,7 @@ def percentage_to_ordered_list_item(ordered_list: List[str], percentage: int) -> """ list_len = len(ordered_list) if not list_len: - raise ValueError + raise ValueError("The ordered list is empty") for offset, speed in enumerate(ordered_list): list_position = offset + 1