instill-core icon indicating copy to clipboard operation
instill-core copied to clipboard

Make error message consistent across all backends

Open xiaofei-du opened this issue 3 years ago • 3 comments
trafficstars

Why I suggest we make the error message consistent across all backends, so the frontend can present more constructive error messages to the users.

Now Right now, our API error returns all error messages in the message field.

{
    "code": 5,
    "message": "a long and detailed error description",
    "details": []
}

How to improve We put a short error description in the message field (generally less than 5 words), and put the long description in details field. Use the above error as an example.

{
    "code": 5,
    "message": "short error description",
    "details": ["a long and detailed error description"]
}

Btw, From Golang docs,

Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with punctuation, since they are usually printed following other context. That is, use fmt.Errorf("something bad") not fmt.Errorf("Something bad"), so that log.Printf("Reading %s: %v", filename, err) formats without a spurious capital letter mid-message. This does not apply to logging, which is implicitly line-oriented and not combined inside other messages.

Let's follow the practice in refactoring.

  • [ ] Pipeline-backend @pinglin
  • [ ] Connector-backend @pinglin
  • [ ] Model-backend @Phelan164
  • [x] Mgmt-backend @xiaofei-du (https://github.com/instill-ai/mgmt-backend/pull/11)

xiaofei-du avatar Jul 01 '22 14:07 xiaofei-du