Error messages should not be masked by matching only on status code
https://github.com/deis/controller/issues/889 is an example of where the return body had a usable error message but got masked by a new custom error message based on the 409 response
I see two solutions to the problem:
- We add error handling for
ErrConflictand add a more explicit method. We already do this here - We parse the body of the
409error message like we do for400errors and return more specific errors.
@helgi Does every 409 have a body? I seem to remember the reason why the error handling in the example above was added in the first place was because the body had no message. If that is the case, perhaps the best solution is a mixture of the two, where some specific errors are returned if the 409 has a body, otherwise return an ErrConflict.
They should usually have a body but not always. Overall I think we should only be overwriting the message from the API if the message is a boilerplate message, such as Not Found or Conflict.
I believe even the one you linked to in the first bullet point has a proper body that shouldn't need to be overwritten. That part of the SDK could be changed as well then