couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r749902 - in /couchdb/trunk/src/couchdb: couch_httpd_db.erl couch_httpd_show.erl
Date Wed, 04 Mar 2009 04:45:10 GMT
Author: jchris
Date: Wed Mar  4 04:45:10 2009
New Revision: 749902

URL: http://svn.apache.org/viewvc?rev=749902&view=rev
Log:
refactor show 404 handling doc-loading special case out of couch_httpd_db.erl

Modified:
    couchdb/trunk/src/couchdb/couch_httpd_db.erl
    couchdb/trunk/src/couchdb/couch_httpd_show.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=749902&r1=749901&r2=749902&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Wed Mar  4 04:45:10 2009
@@ -13,7 +13,7 @@
 -module(couch_httpd_db).
 -include("couch_db.hrl").
 
--export([handle_request/1, db_req/2, couch_doc_open/4, couch_doc_open/5]).
+-export([handle_request/1, db_req/2, couch_doc_open/4]).
 
 -import(couch_httpd,
     [send_json/2,send_json/3,send_json/4,send_method_not_allowed/2,
@@ -538,27 +538,20 @@
 %   couch_doc_open(Db, DocId, [], []).
 
 couch_doc_open(Db, DocId, Rev, Options) ->
-    couch_doc_open(Db, DocId, Rev, Options, true).
-
-couch_doc_open(Db, DocId, Rev, Options, Throw) ->
     case Rev of
     "" -> % open most recent rev
         case couch_db:open_doc(Db, DocId, Options) of
         {ok, Doc} ->
             Doc;
-         Error when Throw ->
-             throw(Error);
-         _ ->
-             nil
+         Error ->
+             throw(Error)
          end;
   _ -> % open a specific rev (deletions come back as stubs)
       case couch_db:open_doc_revs(Db, DocId, [Rev], Options) of
           {ok, [{ok, Doc}]} ->
               Doc;
-          {ok, [Else]} when Throw ->
-              throw(Else);
-          {ok, _} ->
-              nil
+          {ok, [Else]} ->
+              throw(Else)
       end
   end.
 

Modified: couchdb/trunk/src/couchdb/couch_httpd_show.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_show.erl?rev=749902&r1=749901&r2=749902&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_show.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_show.erl Wed Mar  4 04:45:10 2009
@@ -30,7 +30,11 @@
     #doc{body={Props}} = couch_httpd_db:couch_doc_open(Db, DesignId, [], []),
     Lang = proplists:get_value(<<"language">>, Props, <<"javascript">>),
     ShowSrc = get_nested_json_value({Props}, [<<"shows">>, ShowName]),
-    Doc = couch_httpd_db:couch_doc_open(Db, DocId, [], [], false),
+    Doc = try couch_httpd_db:couch_doc_open(Db, DocId, [], []) of
+        FoundDoc -> FoundDoc
+    catch
+        _ -> nil
+    end,
     send_doc_show_response(Lang, ShowSrc, DocId, Doc, Req, Db);
 
 handle_doc_show_req(#httpd{



Mime
View raw message