moonraker: perform error checking when registering remote methods
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
a04e91c046
commit
6efcffa028
|
@ -343,9 +343,12 @@ class Server:
|
||||||
need_klippy_reg: bool = True
|
need_klippy_reg: bool = True
|
||||||
) -> None:
|
) -> None:
|
||||||
if method_name in self.remote_methods:
|
if method_name in self.remote_methods:
|
||||||
# XXX - may want to raise an exception here
|
raise self.error(
|
||||||
logging.info(f"Remote method ({method_name}) already registered")
|
f"Remote method ({method_name}) already registered")
|
||||||
return
|
if self.server_running:
|
||||||
|
raise self.error(
|
||||||
|
f"Failed to register remote method {method_name}, "
|
||||||
|
"methods must be registered during initialization")
|
||||||
self.remote_methods[method_name] = cb
|
self.remote_methods[method_name] = cb
|
||||||
if need_klippy_reg:
|
if need_klippy_reg:
|
||||||
# These methods need to be registered with Klippy
|
# These methods need to be registered with Klippy
|
||||||
|
|
Loading…
Reference in New Issue