diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2009-08-15 05:11:45 +0000 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2009-08-15 05:11:45 +0000 |
commit | 165531bcf223f1c05c4c2eaef7cd2f2943c10584 (patch) | |
tree | 1e1231481683d27940000578f715f4490dcc14d1 /src/couchdb/couch_httpd_misc_handlers.erl | |
parent | f56afb1ea2dbd59262947ed27bb1913394aeb5c6 (diff) |
better failure modes in replication. See COUCHDB-193, COUCHDB-416
If you try to replicate a DB to itself, the replication will proceed, but no
checkpoints will be saved, and the logs will say
"checkpoint failure: conflict (are you replicating to yourself?)"
If you try to specify a non-existent DB as source or target, replication will
fail immediately with a 404. The response body will indicate which DB could
not be opened.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@804436 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_misc_handlers.erl')
-rw-r--r-- | src/couchdb/couch_httpd_misc_handlers.erl | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl index c4f28308..e72f9d2f 100644 --- a/src/couchdb/couch_httpd_misc_handlers.erl +++ b/src/couchdb/couch_httpd_misc_handlers.erl @@ -79,13 +79,16 @@ handle_task_status_req(Req) -> handle_replicate_req(#httpd{method='POST'}=Req) -> PostBody = couch_httpd:json_body_obj(Req), - case couch_rep:replicate(PostBody, Req#httpd.user_ctx) of + try couch_rep:replicate(PostBody, Req#httpd.user_ctx) of {ok, {JsonResults}} -> send_json(Req, {[{ok, true} | JsonResults]}); {error, {Type, Details}} -> send_json(Req, 500, {[{error, Type}, {reason, Details}]}); {error, Reason} -> send_json(Req, 500, {[{error, Reason}]}) + catch + throw:{db_not_found, Msg} -> + send_json(Req, 404, {[{error, db_not_found}, {reason, Msg}]}) end; handle_replicate_req(Req) -> send_method_not_allowed(Req, "POST"). |