diff --git a/src/azure-cli/azure/cli/command_modules/servicebus/custom.py b/src/azure-cli/azure/cli/command_modules/servicebus/custom.py index b610503717e..b6aaeb9b4a5 100644 --- a/src/azure-cli/azure/cli/command_modules/servicebus/custom.py +++ b/src/azure-cli/azure/cli/command_modules/servicebus/custom.py @@ -618,6 +618,7 @@ def return_valid_duration(update_value, current_value=None): from datetime import timedelta from isodate import parse_duration from isodate import Duration + from azure.cli.core.azclierror import InvalidArgumentValueError from azure.cli.command_modules.servicebus.constants import DURATION_SECS, DURATION_MIN, DURATION_DAYS if update_value is not None: value_toreturn = update_value @@ -625,7 +626,10 @@ def return_valid_duration(update_value, current_value=None): return current_value if iso8601pattern.match(value_toreturn): - time_duration = parse_duration(value_toreturn) + try: + time_duration = parse_duration(value_toreturn) + except: + raise InvalidArgumentValueError("Unable to parse provided ISO 8601 format duration %r" % value_toreturn) if isinstance(time_duration, timedelta): if time_duration <= timedelta(days=DURATION_DAYS, minutes=DURATION_MIN, seconds=DURATION_SECS):