goat icon indicating copy to clipboard operation
goat copied to clipboard

[BUG] humanize error responses

Open cinaaaa opened this issue 2 years ago • 3 comments

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 avatar Jul 28 '22 10:07 cinaaaa

@metemaddar

cinaaaa avatar Jul 28 '22 10:07 cinaaaa

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.)

metemaddar avatar Jul 28 '22 11:07 metemaddar

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

EPajares avatar Jul 28 '22 11:07 EPajares