From 6efcffa02887393c16580ce1a384baba7600fed3 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Wed, 9 Feb 2022 06:48:23 -0500 Subject: [PATCH] moonraker: perform error checking when registering remote methods Signed-off-by: Eric Callahan --- moonraker/moonraker.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/moonraker/moonraker.py b/moonraker/moonraker.py index 811ba90..44e2dfc 100755 --- a/moonraker/moonraker.py +++ b/moonraker/moonraker.py @@ -343,9 +343,12 @@ class Server: need_klippy_reg: bool = True ) -> None: if method_name in self.remote_methods: - # XXX - may want to raise an exception here - logging.info(f"Remote method ({method_name}) already registered") - return + raise self.error( + f"Remote method ({method_name}) already registered") + 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 if need_klippy_reg: # These methods need to be registered with Klippy