Monstarrrr / rebutify

Web platform where experts submit rebuttals to common arguments against social justice movements.
https://rebutify.org
5 stars 1 forks source link

Add error responses to API docs #220

Open Monstarrrr opened 5 days ago

Monstarrrr commented 5 days ago

Blocking #219

Problem

Unlike Djoser docs, our API docs do not give any information on Errors. In order to access the error messages properly on the front-end we need a consistent way of sending the error messages.
This is how Djoser seems to handle it:

    /*
      An error can be global or field-specific.

      If an error is global:  
      The status code is 401 || 403 || 404 || 500.
      The error message is a string or an array of strings.
      The message(s) is/are located in error.response.data.detail.

      If an error is field-specific: 
      The status code is 400.
      The error message is an object with field names as keys, and the values are arrays of strings.
      The message(s) is/are located in the array of strings in error.response.data[field_name].
    */

This means that, on the front-end, I read the status code in error.response.status, and then, based on the error code, I will read the error message at the proper location and using the proper variables specified in the API docs.
Without proper documentation, I waste a lot of time figuring out how to handle the errors on the front-end.

Solution

purple-void commented 4 days ago

Seems like @Monstarrrr already is working on this issue. We will unassign ourself