goat-community / goat

This is the home of Geo Open Accessibility Tool (GOAT)
GNU General Public License v3.0
91 stars 47 forks source link

[BUG] humanize error responses #1397

Open cinaaaa opened 2 years ago

cinaaaa commented 2 years ago

Prefer to have a same and more human language like error messages on server error raises

Current Behavior

I get different kind of errors for different apis like detail: {absent_translations: ["VeryHighConnectivity"]} absent_translations: ["VeryHighConnectivity"] 0: "VeryHighConnectivity"

Possible Solution

Just let's have this kind of error msg: 'Invalid translation for x & y

why?

Easy bug tracking and report for us and from non technical customers

cinaaaa commented 2 years ago

@metemaddar

metemaddar commented 2 years ago

Thank you very much Cina. For this specific endpoint we would get two main error messages in response.detail:

  1. List Translations that are needed to add to translations (details.absent_translations). For example for the example response, We have a name in styles with value of "VeryHighConnectivity". But not included at translations. This error lists the keywords that needed to be translated.

    • For example we can create a message for the user like this:

      The translation for x, y, z are not available. Please specify them.

      an example code: The translation for details.absent_translations.join(',') are not available. Please specify them.

  2. if we had details.incomplete_translations. It means that these translations are present in at least one language. But not present in all available languages. For example for this error. we can have the following:

    The translation of x,y,z are not specified for all languages. Please add them first.

But as you said. I think it is a good manner to have such message inside detail.message for example. So that we can simply show the message to the end user. However the con for this manner is that we won't have ability to format the names for example.

In such areas simply having the message is good I think (for example at administration dashboard). But anyway to have complete information at API docs, we need to specify the detailed error messages. like: details.absent_translations or details.incomplete_translations.

So I think maybe we need two tasks in the future:

  1. Add humanize message to the endpoints.
  2. Add error documents to the endpoint docs. (I'm not good at it yet. I need to start it when we get the time.)
EPajares commented 2 years ago

@cinaaaa Thanks for reporting. I will make this a feature request rather than a bug. But definitely something we should tackle in the future.