Graceful error message for abstract base classes in PluginLoader

pull/21780/head
Toshio Kuratomi 8 years ago committed by Brian Coca
parent 374af06cbf
commit c033e5111f

@ -31,7 +31,6 @@ import warnings
from collections import defaultdict
from ansible import constants as C
from ansible.compat.six import string_types
from ansible.module_utils._text import to_text
@ -370,7 +369,14 @@ class PluginLoader:
self._display_plugin_load(self.class_name, name, self._searched_paths, path,
found_in_cache=found_in_cache, class_only=class_only)
if not class_only:
obj = obj(*args, **kwargs)
try:
obj = obj(*args, **kwargs)
except TypeError as e:
if "abstract" in e.args[0]:
# Abstract Base Class. The found plugin file does not
# fully implement the defined interface.
return None
raise
return obj
@ -430,7 +436,10 @@ class PluginLoader:
self._display_plugin_load(self.class_name, name, self._searched_paths, path,
found_in_cache=found_in_cache, class_only=class_only)
if not class_only:
obj = obj(*args, **kwargs)
try:
obj = obj(*args, **kwargs)
except TypeError as e:
display.warning("Skipping plugin (%s) as it seems to be incomplete: %s" % (path, to_text(e)))
# set extra info on the module, in case we want it later
setattr(obj, '_original_path', path)

Loading…
Cancel
Save