Skip to content

Commit

Permalink
Improve error message for tuning step failure
Browse files Browse the repository at this point in the history
This improves the message we show to the user when they enter a
frequency that can't be supported by the radio due to step alignment
support.
  • Loading branch information
kk7ds committed Nov 15, 2024
1 parent 71812ad commit 4b03055
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions chirp/chirp_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,9 +1783,12 @@ def required_step(freq, allowed=None):
}

# Try the above "standard" steps first in order
required_step = None
for step, validate in steps.items():
if step in allowed and validate(freq):
return step
elif validate(freq) and required_step is None:
required_step = step

# Try any additional steps in the allowed list
for step in allowed:
Expand All @@ -1797,8 +1800,14 @@ def required_step(freq, allowed=None):
step, format_freq(freq)))
return step

raise errors.InvalidDataError("Unable to find a supported " +
"tuning step for %s" % format_freq(freq))
if required_step is not None:
raise errors.InvalidDataError((
'Frequency %s requires step %.2f, '
'which is not supported') % (
format_freq(freq), required_step))
else:
raise errors.InvalidDataError("Unable to find a supported " +
"tuning step for %s" % format_freq(freq))


def fix_rounded_step(freq):
Expand Down

0 comments on commit 4b03055

Please sign in to comment.