mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 14:28:48 +00:00
reafactor
This commit is contained in:
parent
9bb6bb294c
commit
9b02e3bdb7
@ -9,20 +9,6 @@ from django.conf import settings
|
|||||||
|
|
||||||
|
|
||||||
# region logging / errors
|
# region logging / errors
|
||||||
def log_error(error, reference: str = 'general'):
|
|
||||||
"""
|
|
||||||
Log an plugin error
|
|
||||||
"""
|
|
||||||
from plugin import registry
|
|
||||||
|
|
||||||
# make sure the registry is set up
|
|
||||||
if reference not in registry.errors:
|
|
||||||
registry.errors[reference] = []
|
|
||||||
|
|
||||||
# add error to stack
|
|
||||||
registry.errors[reference].append(error)
|
|
||||||
|
|
||||||
|
|
||||||
class IntegrationPluginError(Exception):
|
class IntegrationPluginError(Exception):
|
||||||
"""
|
"""
|
||||||
Error that encapsulates another error and adds the path / reference of the raising plugin
|
Error that encapsulates another error and adds the path / reference of the raising plugin
|
||||||
@ -50,6 +36,20 @@ class MixinNotImplementedError(NotImplementedError):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def log_error(error, reference: str = 'general'):
|
||||||
|
"""
|
||||||
|
Log an plugin error
|
||||||
|
"""
|
||||||
|
from plugin import registry
|
||||||
|
|
||||||
|
# make sure the registry is set up
|
||||||
|
if reference not in registry.errors:
|
||||||
|
registry.errors[reference] = []
|
||||||
|
|
||||||
|
# add error to stack
|
||||||
|
registry.errors[reference].append(error)
|
||||||
|
|
||||||
|
|
||||||
def handle_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
|
Handles an error and casts it as an IntegrationPluginError
|
||||||
|
Loading…
x
Reference in New Issue
Block a user