mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
rename
This commit is contained in:
parent
67a501f438
commit
9bb6bb294c
@ -50,7 +50,7 @@ class MixinNotImplementedError(NotImplementedError):
|
||||
pass
|
||||
|
||||
|
||||
def handle_plugin_error(error, do_raise: bool = True, do_log: bool = True, do_return: bool = False, log_name: str = ''):
|
||||
def handle_error(error, do_raise: bool = True, do_log: bool = True, do_return: bool = False, log_name: str = ''):
|
||||
"""
|
||||
Handles an error and casts it as an IntegrationPluginError
|
||||
"""
|
||||
|
@ -15,7 +15,7 @@ def iter_namespace(pkg):
|
||||
|
||||
def get_modules(pkg, recursive: bool = False):
|
||||
"""get all modules in a package"""
|
||||
from plugin.helpers import log_plugin_error
|
||||
from plugin.helpers import log_error
|
||||
|
||||
if not recursive:
|
||||
return [importlib.import_module(name) for finder, name, ispkg in iter_namespace(pkg)]
|
||||
@ -35,7 +35,7 @@ def get_modules(pkg, recursive: bool = False):
|
||||
# this 'protects' against malformed plugin modules by more or less silently failing
|
||||
|
||||
# log to stack
|
||||
log_plugin_error({name: str(error)}, 'discovery')
|
||||
log_error({name: str(error)}, 'discovery')
|
||||
|
||||
return [v for k, v in context.items()]
|
||||
|
||||
|
@ -30,7 +30,7 @@ from maintenance_mode.core import get_maintenance_mode, set_maintenance_mode
|
||||
|
||||
from plugin import plugins as inventree_plugins
|
||||
from .integration import IntegrationPluginBase
|
||||
from .helpers import handle_plugin_error, IntegrationPluginError
|
||||
from .helpers import handle_error, IntegrationPluginError
|
||||
|
||||
|
||||
logger = logging.getLogger('inventree')
|
||||
@ -67,7 +67,7 @@ class PluginsRegistry:
|
||||
Load and activate all IntegrationPlugins
|
||||
"""
|
||||
|
||||
from plugin.helpers import log_plugin_error
|
||||
from plugin.helpers import log_error
|
||||
|
||||
logger.info('Start loading plugins')
|
||||
|
||||
@ -91,7 +91,7 @@ class PluginsRegistry:
|
||||
break
|
||||
except IntegrationPluginError as error:
|
||||
logger.error(f'[PLUGIN] Encountered an error with {error.path}:\n{error.message}')
|
||||
log_plugin_error({error.path: error.message}, 'load')
|
||||
log_error({error.path: error.message}, 'load')
|
||||
blocked_plugin = error.path # we will not try to load this app again
|
||||
|
||||
# Initialize apps without any integration plugins
|
||||
@ -180,7 +180,7 @@ class PluginsRegistry:
|
||||
plugin.is_package = True
|
||||
self.plugin_modules.append(plugin)
|
||||
except Exception as error:
|
||||
handle_plugin_error(error, do_raise=False, log_name='discovery')
|
||||
handle_error(error, do_raise=False, log_name='discovery')
|
||||
|
||||
# Log collected plugins
|
||||
logger.info(f'Collected {len(self.plugin_modules)} plugins!')
|
||||
@ -259,7 +259,7 @@ class PluginsRegistry:
|
||||
plugin = plugin()
|
||||
except Exception as error:
|
||||
# log error and raise it -> disable plugin
|
||||
handle_plugin_error(error, log_name='init')
|
||||
handle_error(error, log_name='init')
|
||||
|
||||
logger.info(f'Loaded integration plugin {plugin.slug}')
|
||||
plugin.is_package = was_packaged
|
||||
@ -543,7 +543,7 @@ class PluginsRegistry:
|
||||
cmd(*args, **kwargs)
|
||||
return True, []
|
||||
except Exception as error:
|
||||
handle_plugin_error(error)
|
||||
handle_error(error)
|
||||
# endregion
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user