Skip to content

Commit

Permalink
handle values with units, better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Nov 14, 2023
1 parent 857a5e4 commit 72c8150
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions xpra/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,10 +1216,13 @@ def parse_with_unit(numtype:str, v, subunit="bps", min_value=250000) -> int | No
f *= 1000000
elif unit=="g":
f *= 1000000000
elif unit != "":
pass #no multiplier
elif unit!="b":
raise ValueError(f"unknown unit {unit}")
raise ValueError(f"unknown unit {unit!r}")
if min_value is not None:
assert f>=min_value, "value is too low"
if f<min_value:
raise ValueError(f"value {f} is too low, minimum is {min_value}")
return int(f)
except Exception as e:
raise InitException(f"invalid value for {numtype} {v!r}: {e}") from None
Expand Down

0 comments on commit 72c8150

Please sign in to comment.