diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2019-06-18 22:43:21 -0400 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2019-06-18 22:43:21 -0400 |
commit | 6f95fb3c0a35059c1a2ae4970605d1034cf799d8 (patch) | |
tree | 6c31969f73210ced7c402c0539b135a292d78702 | |
parent | 93275c34f1140fec306e2822aa30943d40759e4b (diff) | |
download | couchdb-6f95fb3c0a35059c1a2ae4970605d1034cf799d8.tar.gz |
Improve error message on Clouseau connection fail
-rw-r--r-- | src/dreyfus/src/dreyfus_httpd.erl | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/dreyfus/src/dreyfus_httpd.erl b/src/dreyfus/src/dreyfus_httpd.erl index b6dd6134e..5c9db80d1 100644 --- a/src/dreyfus/src/dreyfus_httpd.erl +++ b/src/dreyfus/src/dreyfus_httpd.erl @@ -575,18 +575,25 @@ send_grouped_response(Req, {TotalHits, TotalGroupedHits, Groups}, UseNewApi) -> end, send_json(Req, 200, {GroupResponsePairs}). -handle_error(Req, Db, DDoc, RetryCount, RetryPause, {exit, _}) -> - backoff_and_retry(Req, Db, DDoc, RetryCount, RetryPause); -handle_error(Req, Db, DDoc, RetryCount, RetryPause, {{normal, _}, _}) -> - backoff_and_retry(Req, Db, DDoc, RetryPause, RetryCount); +handle_error(Req, Db, DDoc, RetryCount, RetryPause, {exit, _} = Err) -> + backoff_and_retry(Req, Db, DDoc, RetryCount, RetryPause, Err); +handle_error(Req, Db, DDoc, RetryCount, RetryPause, {{normal, _}, _} = Err) -> + backoff_and_retry(Req, Db, DDoc, RetryPause, RetryCount, Err); handle_error(Req, _Db, _DDoc, _RetryCount, _RetryPause, Reason) -> send_error(Req, Reason). -backoff_and_retry(Req, Db, DDoc, RetryCount, RetryPause) -> +backoff_and_retry(Req, Db, DDoc, RetryCount, RetryPause, Error) -> RetryLimit = list_to_integer(config:get("dreyfus", "retry_limit", "5")), case RetryCount > RetryLimit of true -> - send_error(Req, timeout); + case Error of + {exit, noconnection} -> + SvcName = config:get("dreyfus", "name", "clouseau@127.0.0.1"), + ErrMsg = "Could not connect to the Clouseau Java service at " ++ SvcName, + send_error(Req, {ou_est_clouseau, ErrMsg}); + _ -> + send_error(Req, timeout) + end; false -> timer:sleep(RetryPause), handle_search_req(Req, Db, DDoc, RetryCount + 1, RetryPause * 2) |