Untitled

mail@pastecode.io avatar
unknown
plain_text
22 days ago
459 B
2
Indexable
Never
from rest_framework.exceptions import APIException



class CustomSerializedException(APIException):



    def __init__(self, message, code):
        self.message = message
        self.code = code
        super().__init__(detail=message, code=code)





try:
    raise CustomSerializedException("Custom message", "CUSTOM_CODE")
except CustomSerializedException as e:
    print(f"Caught custom exception: {e.message}, Code: {e.code}")
Leave a Comment