mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-02-08 09:10:56 -07:00
gcode: enrich param errors
Give suggestion or avaliable options to the user. Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
This commit is contained in:
parent
0dff097b72
commit
c2d0cc1967
1 changed files with 12 additions and 2 deletions
|
|
@ -321,8 +321,18 @@ class GCodeDispatch:
|
|||
else:
|
||||
key_param = gcmd.get(key)
|
||||
if key_param not in values:
|
||||
raise gcmd.error("The value '%s' is not valid for %s"
|
||||
% (key_param, key))
|
||||
keys = []
|
||||
guess = ""
|
||||
for value in values:
|
||||
if value is None:
|
||||
continue
|
||||
keys.append("\'%s\'" % value)
|
||||
if len(key_param) and key_param in value:
|
||||
guess = ". Did you mean \'%s\'?" % value
|
||||
if guess == "":
|
||||
guess = ". Options: %s" % (", ".join(k for k in keys))
|
||||
raise gcmd.error("The value '%s' is not valid for %s%s"
|
||||
% (key_param, key, guess))
|
||||
values[key_param](gcmd)
|
||||
# Low-level G-Code commands that are needed before the config file is loaded
|
||||
def cmd_M110(self, gcmd):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue