Untitled

 avatar
unknown
plain_text
a year ago
459 B
5
Indexable
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}")
Editor is loading...
Leave a Comment