1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #9075: Introduce AbortRequest exception for cleanly interrupting object mutations

This commit is contained in:
jeremystretch
2022-06-30 15:15:07 -04:00
parent 65f4895dd6
commit 3a6f46bf38
7 changed files with 95 additions and 36 deletions

View File

@ -1,6 +1,13 @@
from rest_framework import status
from rest_framework.exceptions import APIException
__all__ = (
'AbortRequest',
'AbortTransaction',
'PermissionsViolation',
'RQWorkerNotRunningException',
)
class AbortTransaction(Exception):
"""
@ -9,12 +16,20 @@ class AbortTransaction(Exception):
pass
class AbortRequest(Exception):
"""
Raised to cleanly abort a request (for example, by a pre_save signal receiver).
"""
def __init__(self, message):
self.message = message
class PermissionsViolation(Exception):
"""
Raised when an operation was prevented because it would violate the
allowed permissions.
"""
pass
message = "Operation failed due to object-level permissions violation"
class RQWorkerNotRunningException(APIException):