You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2019/06/19 02:44:42 UTC

[couchdb] 01/01: Improve error message on Clouseau connection fail

This is an automated email from the ASF dual-hosted git repository.

kocolosk pushed a commit to branch dreyfus-by-default
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 6f95fb3c0a35059c1a2ae4970605d1034cf799d8
Author: Adam Kocoloski <ko...@apache.org>
AuthorDate: Tue Jun 18 22:43:21 2019 -0400

    Improve error message on Clouseau connection fail
---
 src/dreyfus/src/dreyfus_httpd.erl | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/dreyfus/src/dreyfus_httpd.erl b/src/dreyfus/src/dreyfus_httpd.erl
index b6dd613..5c9db80 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)