Commit 5b1344f
committed
fix: handle non-numeric input for multiple-choice parameters in set_new_value
The is_multiple_choice branch in set_new_value called float(s) with
no try/except block. Both the is_bitmask and numeric branches properly
catch ValueError and raise user-friendly translated error messages.
If a user types a non-numeric string for a multiple-choice parameter
(e.g. the choice label 'Disabled' instead of its numeric key '0'),
the raw Python error 'could not convert string to float' was raised
instead of a friendly translated message.
Fixed by wrapping float(s) in a try/except ValueError matching the
pattern already used in the bitmask and numeric branches.
Add two regression tests covering the non-numeric error case and
the valid numeric input case.1 parent fd67e1c commit 5b1344f
2 files changed
Lines changed: 3 additions & 3 deletions
File tree
- ardupilot_methodic_configurator
- tests
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
376 | | - | |
377 | | - | |
| 375 | + | |
378 | 376 | | |
379 | 377 | | |
380 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1155 | 1155 | | |
1156 | 1156 | | |
1157 | 1157 | | |
| 1158 | + | |
| 1159 | + | |
1158 | 1160 | | |
1159 | 1161 | | |
1160 | 1162 | | |
| |||
0 commit comments