reafactor

This commit is contained in:
Matthias 2022-01-11 01:13:36 +01:00
parent 9bb6bb294c
commit 9b02e3bdb7
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -9,20 +9,6 @@ from django.conf import settings
# 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):
"""
Error that encapsulates another error and adds the path / reference of the raising plugin
@ -50,6 +36,20 @@ class MixinNotImplementedError(NotImplementedError):
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 = ''):
"""
Handles an error and casts it as an IntegrationPluginError