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

iilyak pushed a commit to branch retry-on-noproc-errors-2
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 50dc383d65a1516471c2a90463a28ec44e99dbb9
Author: ILYA Khlopotov <[email protected]>
AuthorDate: Thu Sep 11 11:55:10 2025 -0700

    Refactor dreyfus_rpc:call using maybe
---
 src/dreyfus/src/dreyfus_rpc.erl | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/dreyfus/src/dreyfus_rpc.erl b/src/dreyfus/src/dreyfus_rpc.erl
index ca6c74220..11076a63e 100644
--- a/src/dreyfus/src/dreyfus_rpc.erl
+++ b/src/dreyfus/src/dreyfus_rpc.erl
@@ -13,6 +13,9 @@
 %% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
 
 -module(dreyfus_rpc).
+
+-feature(maybe_expr, enable).
+
 -include_lib("couch/include/couch_db.hrl").
 -include("dreyfus.hrl").
 -import(couch_query_servers, [get_os_process/1, ret_os_process/1, 
proc_prompt/2]).
@@ -44,14 +47,11 @@ call(Fun, DbName, DDoc, IndexName, QueryArgs0) ->
         stale = Stale
     } = QueryArgs,
     {_LastSeq, MinSeq} = calculate_seqs(Db, Stale),
-    case dreyfus_index:design_doc_to_index(DDoc, IndexName) of
-        {ok, Index} ->
-            case dreyfus_index_manager:get_index(DbName, Index) of
-                {ok, Pid} ->
-                    rexi:reply(index_call(Fun, Pid, MinSeq, QueryArgs));
-                Error ->
-                    rexi:reply(Error)
-            end;
+    maybe
+        {ok, Index} ?= dreyfus_index:design_doc_to_index(DDoc, IndexName),
+        {ok, Pid} ?= dreyfus_index_manager:get_index(DbName, Index),
+        rexi:reply(index_call(Fun, Pid, MinSeq, QueryArgs))
+    else
         Error ->
             rexi:reply(Error)
     end.

Reply via email to