You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2020/08/20 19:47:51 UTC

[couchdb] 01/01: Do not use (catch ...) in couch_views_reader:load_docs/4

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

vatamane pushed a commit to branch do_not_use_catch_in_view_load_doc
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit ecc4f422214028def3b1e0dade3632c3732273f4
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu Aug 20 15:36:38 2020 -0400

    Do not use (catch ...) in couch_views_reader:load_docs/4
    
    Any error there would just be generating a case clause.
    
    Remove the `_Else` catch-all clause too as `open_doc_revs/4` should return a
    list of just one item that is either `{ok, Doc}` or `{{not_found, missing},
    Rev}`. That's because it is called with just single [Rev1] parameter and view
    `#mrargs` can't have the `latest` doc_options option present [1].
    
    [1] https://github.com/apache/couchdb/blob/prototype/fdb-layer/src/couch_mrview/src/couch_mrview_http.erl#L491
---
 src/couch_views/src/couch_views_reader.erl | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/couch_views/src/couch_views_reader.erl b/src/couch_views/src/couch_views_reader.erl
index ce7f163..141cf94 100644
--- a/src/couch_views/src/couch_views_reader.erl
+++ b/src/couch_views/src/couch_views_reader.erl
@@ -210,8 +210,7 @@ load_doc(TxDb, Id, null, DocOpts) ->
 
 load_doc(TxDb, Id, Rev, DocOpts) ->
     Rev1 = couch_doc:parse_rev(Rev),
-    case (catch fabric2_db:open_doc_revs(TxDb, Id, [Rev1], DocOpts)) of
+    case fabric2_db:open_doc_revs(TxDb, Id, [Rev1], DocOpts) of
         {ok, [{ok, Doc}]} -> couch_doc:to_json_obj(Doc, DocOpts);
-        {ok, [{{not_found, missing}, Rev}]} -> null;
-        {ok, [_Else]} -> null
+        {ok, [{{not_found, missing}, Rev}]} -> null
     end.