also handle errors on internal plugins

This commit is contained in:
Matthias 2021-11-21 23:51:36 +01:00
parent 2e28bb225f
commit f71b40e031
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -32,7 +32,10 @@ class IntegrationPluginError(Exception):
def get_plugin_error(error, do_raise: bool = False, do_log: bool = False, log_name: str = ''): def get_plugin_error(error, do_raise: bool = False, do_log: bool = False, log_name: str = ''):
package_path = traceback.extract_tb(error.__traceback__)[-1].filename package_path = traceback.extract_tb(error.__traceback__)[-1].filename
install_path = sysconfig.get_paths()["purelib"] install_path = sysconfig.get_paths()["purelib"]
package_name = pathlib.Path(package_path).relative_to(install_path).parts[0] try:
package_name = pathlib.Path(package_path).relative_to(install_path).parts[0]
except ValueError:
package_name = pathlib.Path(package_path).relative_to(settings.BASE_DIR)
if do_log: if do_log:
log_kwargs = {} log_kwargs = {}