benoitc / couchbeam

Apache CouchDB client in Erlang
Other
242 stars 113 forks source link

Return response body for error conditions from make_response/1 in couchbeam_resource.erl #23

Closed jeraymond closed 13 years ago

jeraymond commented 14 years ago

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

benoitc commented 14 years ago

Thank you. I'm working on this.

benoitc commented 13 years ago

Ouch tthat's an old issue. Fixed in last head. Sorry for the delay.

jeraymond commented 13 years ago

Cool, thanks.