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 .models import App
|
||||||
from .links import app_registry_tool_link
|
from .links import app_registry_tool_link
|
||||||
|
from .exceptions import UnableToRegister
|
||||||
|
|
||||||
|
|
||||||
@transaction.commit_on_success
|
@transaction.commit_on_success
|
||||||
@@ -12,7 +13,7 @@ def register_app(name, label, icon=None):
|
|||||||
app, created = App.objects.get_or_create(name=name)
|
app, created = App.objects.get_or_create(name=name)
|
||||||
except DatabaseError:
|
except DatabaseError:
|
||||||
transaction.rollback()
|
transaction.rollback()
|
||||||
return None
|
raise UnableToRegister
|
||||||
else:
|
else:
|
||||||
app.label = label
|
app.label = label
|
||||||
if icon:
|
if icon:
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
class UnableToRegister(Exception):
|
||||||
|
pass
|
||||||
Reference in New Issue
Block a user