eadwinCode/django-ninja-extra

Error Handling : Custom Exception message does not work

Closed this issue · 4 comments

When defining a custom Error class which extends APIException,
when raising the exception, we got :
{
"detail": "A server error occurred."
}

instead of the custom message of the exception

exceptions

api_exception

swagger_error

@Jocelyn-AGORO

class BadRequestException(APIException):
    status_code = status.HTTP_400_BAD_REQUEST
    default_detail = "Bad Request: " 
    

message should be changed to default_detail

Ok, I try it it works now. Thank You.
You need to change it on the documentation.

doc_error
https://eadwincode.github.io/django-ninja-extra/tutorial/custom_exception/

Oh I see... Thanks @Jocelyn-AGORO
I will do that shortly

@Jocelyn-AGORO This is now resolved