dolanor/rip

ErrorCodeBadQArg should use standard status code

dolmen opened this issue · 3 comments

ErrorCodeBadQArg should be 406 or 400, not 499.

Most of the rip.ErrorCodeXxx have a direct equivalent in http.StatusXxx.
For the case where it was more specific to rip or it didn't have a 1-to-1 mapping, I used an arbitrary code that I would then switch to a normal http.StatusXxx code.

In this case, the 499 -> gets mapped to 400.
https://github.com/dolanor/rip/blob/main/error.go#L109-L112

The idea was to add extra info in the error type returned. For example, I could use the rip.Error.Source.Header to indicate it was the Accept header ;q=x.y argument that is faulty. I didn't have it at the time I created the error, and now I can see that I didn't set it in my new error type (It's kind of an unfinished business, the error system, for now)

Well, does ErrorCodeBadQArg need to be public, or is it only for internal use?

Good point, I don't see any reason for a user of rip to need it. So internal. I'll make it private.