Porównaj commity

...

2 Commity

Autor SHA1 Wiadomość Data
Piero Toffanin 206edf1087
Merge pull request #1467 from gonzalo-bulnes/fix-plugin-error-shadowing
Fix error shadowing in log when plugin fails to load
2024-02-08 23:59:22 -05:00
Gonzalo Bulnes Guilpain 7c9b1da92a
Fix error shadowing in log when plugin fails to load
I didn't find a standard way of unwrapping the error,
short of printing an entire stack trace. I don't think printing
a stack trace in a log is useful, so I decided to print
the error.__cause__ explicitly.

Since there is always one single level of nesting in this code,
I think that's OK.

See https://docs.python.org/3/library/exceptions.html
2024-02-08 22:07:15 -05:00
1 zmienionych plików z 7 dodań i 4 usunięć

Wyświetl plik

@ -210,9 +210,12 @@ def get_plugins():
module = importlib.import_module("plugins.{}".format(dir))
plugin = (getattr(module, "Plugin"))()
except (ImportError, AttributeError):
module = importlib.import_module("coreplugins.{}".format(dir))
plugin = (getattr(module, "Plugin"))()
except (ImportError, AttributeError) as plugin_error:
try:
module = importlib.import_module("coreplugins.{}".format(dir))
plugin = (getattr(module, "Plugin"))()
except (ImportError, AttributeError) as coreplugin_error:
raise coreplugin_error from plugin_error
# Check version
manifest = plugin.get_manifest()
@ -237,7 +240,7 @@ def get_plugins():
plugins.append(plugin)
except Exception as e:
logger.warning("Failed to instantiate plugin {}: {}".format(dir, e))
logger.warning("Failed to instantiate plugin {}: {}: {}".format(dir, e, e.__cause__))
return plugins