Initial commit

This commit is contained in:
2025-01-20 14:33:03 +05:00
commit 4d0eb86478
84 changed files with 4436 additions and 0 deletions

18
api/exceptions.py Normal file
View File

@ -0,0 +1,18 @@
from rest_framework.views import exception_handler
from rest_framework.exceptions import Throttled
def custom_exception_handler(exc, context):
# Call REST framework's default exception handler first,
# to get the standard error response.
response = exception_handler(exc, context)
if isinstance(exc, Throttled): # check that a Throttled exception is raised
custom_response_data = { # prepare custom response data
"message": "Too many attemps. Please Try again in %d seconds." % exc.wait,
}
response.data = (
custom_response_data # set the custom response data on response object
)
return response