1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
Jeremy Stretch d470848b29 Closes #12246: General cleanup of utilities modules
* Clean up base modules

* Clean up forms modules

* Clean up templatetags modules

* Replace custom simplify_decimal filter with floatformat

* Misc cleanup

* Merge ReturnURLForm into ConfirmationForm

* Clean up import statements for utilities.forms

* Fix field class references in docs
2023-04-14 10:33:53 -04:00

51 lines
1.2 KiB
Python

from rest_framework import status
from rest_framework.exceptions import APIException
__all__ = (
'AbortRequest',
'AbortScript',
'AbortTransaction',
'PermissionsViolation',
'RQWorkerNotRunningException',
)
class AbortTransaction(Exception):
"""
A dummy exception used to trigger a database transaction rollback.
"""
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 AbortScript(Exception):
"""
Raised to cleanly abort a script.
"""
pass
class PermissionsViolation(Exception):
"""
Raised when an operation was prevented because it would violate the
allowed permissions.
"""
message = "Operation failed due to object-level permissions violation"
class RQWorkerNotRunningException(APIException):
"""
Indicates the temporary inability to enqueue a new task (e.g. custom script execution) because no RQ worker
processes are currently running.
"""
status_code = status.HTTP_503_SERVICE_UNAVAILABLE
default_detail = 'Unable to process request: RQ worker process not running.'
default_code = 'rq_worker_not_running'