Skip to content

Commit

Permalink
Print error rather than exception in log for expected AttributeError
Browse files Browse the repository at this point in the history
  • Loading branch information
kizniche committed Feb 14, 2024
1 parent d97d2b3 commit 715ceac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mycodo/controllers/controller_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ def initialize_variables(self):
def call_module_function(self, button_id, args_dict, thread=True, return_from_function=False):
"""Execute function from custom action button press."""
try:
run_command = getattr(self.run_function, button_id)
try:
run_command = getattr(self.run_function, button_id)
except AttributeError:
msg = f"{button_id}() not found in module. Module may currently be initializing or may be missing the function."
self.logger.error(msg)
return 1, msg
if not thread or return_from_function:
return_val = run_command(args_dict)
if return_from_function:
Expand Down

0 comments on commit 715ceac

Please sign in to comment.