pixelpassion / django-saas-boilerplate

A Django + django-rest-framework + Heroku + SaaS application boilerplate
MIT License
51 stars 10 forks source link

Custom exception handling #35

Open jensneuhaus opened 4 years ago

jensneuhaus commented 4 years ago

☝️What is it? Why do we need it?

django-rest-framework works great but the exception handling is not as good because it mixes HTML responses (e.g. 404 or 500) with JSON responses

For the API the format should be consistent:

{
   "message" : "This is a user message, we might show to the User"
   "error_code": "PASSWORD_TOO_INSECURE"
}

Please write a custom exception handler which we can use in all kind of projects, documentation on this is here: https://www.django-rest-framework.org/api-guide/exceptions/#custom-exception-handling

📋 Todos