make_response(#response{method=Method, status=Status, reason=Reason, body=Body}) ->
if
Status >= 400, Status == 404 ->
{error, not_found};
Status >= 400, Status == 409 ->
{error, conflict};
Status >= 400, Status == 412 ->
{error, precondition_failed};
Status >= 400 ->
{error, {unknown_error, Status}};
...
It'd be useful if the Body was also returned with the error message to provide more information about the error. For example, if I have a design doc with a validate_doc_update() function and the doc I'm trying to create fails validation I get back {unknown_error, 403}. It'd be much more useful if I got back something like {unknown_error, 403, "missing user field"} or whatever the error message was that was returned.
Could all error conditions also return the body that comes back from couchdb to provide the application more information?
In make_response/1 there are the conditions:
make_response(#response{method=Method, status=Status, reason=Reason, body=Body}) -> if Status >= 400, Status == 404 -> {error, not_found}; Status >= 400, Status == 409 -> {error, conflict}; Status >= 400, Status == 412 -> {error, precondition_failed}; Status >= 400 -> {error, {unknown_error, Status}}; ... It'd be useful if the Body was also returned with the error message to provide more information about the error. For example, if I have a design doc with a validate_doc_update() function and the doc I'm trying to create fails validation I get back {unknown_error, 403}. It'd be much more useful if I got back something like {unknown_error, 403, "missing user field"} or whatever the error message was that was returned.
Could all error conditions also return the body that comes back from couchdb to provide the application more information?
Thanks,
Jeremy