From ddbe76646b0c86ae9be7a55c28f7ffea29598082 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 10 Jan 2020 00:07:40 +0100 Subject: [PATCH] Throw an assert error (no reload/retry mechanism) instead of a runtime error when a method is called outside of the registered plugin actions --- platypush/plugins/__init__.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/platypush/plugins/__init__.py b/platypush/plugins/__init__.py index 470507c4..01f8de29 100644 --- a/platypush/plugins/__init__.py +++ b/platypush/plugins/__init__.py @@ -45,15 +45,12 @@ class Plugin(EventGenerator): self.logger.setLevel(getattr(logging, kwargs['logging'].upper())) self.registered_actions = set( - get_decorators(self.__class__, climb_class_hierarchy=True) - .get('action', []) + get_decorators(self.__class__, climb_class_hierarchy=True).get('action', []) ) def run(self, method, *args, **kwargs): - if method not in self.registered_actions: - raise RuntimeError('{} is not a registered action on {}'.format( - method, self.__class__.__name__)) - + assert method in self.registered_actions, '{} is not a registered action on {}'.\ + format(method, self.__class__.__name__) return getattr(self, method)(*args, **kwargs)