summaryrefslogtreecommitdiff
path: root/apps/couch/src/couch_httpd_misc_handlers.erl
diff options
context:
space:
mode:
Diffstat (limited to 'apps/couch/src/couch_httpd_misc_handlers.erl')
-rw-r--r--apps/couch/src/couch_httpd_misc_handlers.erl11
1 files changed, 9 insertions, 2 deletions
diff --git a/apps/couch/src/couch_httpd_misc_handlers.erl b/apps/couch/src/couch_httpd_misc_handlers.erl
index 7b09dccd..7a149d11 100644
--- a/apps/couch/src/couch_httpd_misc_handlers.erl
+++ b/apps/couch/src/couch_httpd_misc_handlers.erl
@@ -93,10 +93,17 @@ handle_replicate_req(#httpd{method='POST'}=Req) ->
{error, not_found} ->
send_json(Req, 404, {[{error, not_found}]});
{error, Reason} ->
- send_json(Req, 500, {[{error, Reason}]})
+ try
+ send_json(Req, 500, {[{error, Reason}]})
+ catch
+ exit:{json_encode, _} ->
+ send_json(Req, 500, {[{error, couch_util:to_binary(Reason)}]})
+ end
catch
throw:{db_not_found, Msg} ->
- send_json(Req, 404, {[{error, db_not_found}, {reason, Msg}]})
+ send_json(Req, 404, {[{error, db_not_found}, {reason, Msg}]});
+ throw:{unauthorized, Msg} ->
+ send_json(Req, 404, {[{error, unauthorized}, {reason, Msg}]})
end;
handle_replicate_req(Req) ->
send_method_not_allowed(Req, "POST").