rcrowley / go-tigertonic

A Go framework for building JSON web services inspired by Dropwizard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Return Error Messages

everclear opened this issue · 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"
}

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