mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Provide a human readable exception for the percentage util (#47121)
This commit is contained in:
parent
84e01baa5a
commit
86f8cd8037
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user