Add exception for when unable to register an App
This commit is contained in:
@@ -4,6 +4,7 @@ from django.db import DatabaseError, transaction
|
||||
|
||||
from .models import App
|
||||
from .links import app_registry_tool_link
|
||||
from .exceptions import UnableToRegister
|
||||
|
||||
|
||||
@transaction.commit_on_success
|
||||
@@ -12,7 +13,7 @@ def register_app(name, label, icon=None):
|
||||
app, created = App.objects.get_or_create(name=name)
|
||||
except DatabaseError:
|
||||
transaction.rollback()
|
||||
return None
|
||||
raise UnableToRegister
|
||||
else:
|
||||
app.label = label
|
||||
if icon:
|
||||
|
||||
2
apps/app_registry/exceptions.py
Normal file
2
apps/app_registry/exceptions.py
Normal file
@@ -0,0 +1,2 @@
|
||||
class UnableToRegister(Exception):
|
||||
pass
|
||||
Reference in New Issue
Block a user