From dab0c11af4a788d7144e55af9bdc5af9ab607211 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Thu, 26 Oct 2023 15:30:08 -0300 Subject: [PATCH] improve error message when parentheses cannot be found in descriptor --- hwilib/descriptor.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hwilib/descriptor.py b/hwilib/descriptor.py index 31b1480a5..311c78028 100644 --- a/hwilib/descriptor.py +++ b/hwilib/descriptor.py @@ -432,9 +432,12 @@ def _get_func_expr(s: str) -> Tuple[str, str]: :return: The function name as the first element of the tuple, and the expression contained within the function as the second element :raises: ValueError: if a matching pair of parentheses cannot be found """ - start = s.index("(") - end = s.rindex(")") - return s[0:start], s[start + 1:end] + try: + start = s.index("(") + end = s.rindex(")") + return s[0:start], s[start + 1:end] + except ValueError: + raise ValueError("A matching pair of parentheses cannot be found") def _get_const(s: str, const: str) -> str: