go-tigertonic icon indicating copy to clipboard operation
go-tigertonic copied to clipboard

Return Error Messages

Open everclear opened this issue 10 years ago • 1 comments

This is a non issue really, I'm just curious! What's the design reason for spitting out the 'kind' of error? I don't get the benefit of return it to the end user (and exposing internals).

{
  "description": "Invalid id given",
  "error": "validator.Errors"
}

vs

{
  "error": "Invalid id given"
}

everclear avatar Mar 31 '15 13:03 everclear

Not sure about validator errors, but in general normal errors like 404s and 400s will look like:

{"error": "bad_request", "description": "foo"}

This could be useful if, say, you're logging responses; the error string indicates what kind of error it is. I imagine validator errors are even more useful, as a simple 400 status code or "bad_request" error value tells you nothing about what specific kind of problem there was. I guess you have to ensure validator errors don't contain sensitive info, or if you can't, then don't use them (I don't have experience with validators, myself).

willfaught avatar Apr 10 '15 18:04 willfaught