diff options
author | Jan Lehnardt <jan@apache.org> | 2009-03-04 00:15:07 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-03-04 00:15:07 +0000 |
commit | 446735bf7d60831b800275e3bb85251e4d6f8e38 (patch) | |
tree | fd4a11092366fec7b2bc1cbf2659645e1d1b4997 /src/couchdb/couch_httpd_db.erl | |
parent | 5ce28dab2a2f803efdc6ae4d1a39e82d758cec57 (diff) |
allow for handling 404s in document show functions
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@749852 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_db.erl')
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 524b52b4..1bd853f3 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -13,7 +13,7 @@ -module(couch_httpd_db). -include("couch_db.hrl"). --export([handle_request/1, db_req/2, couch_doc_open/4]). +-export([handle_request/1, db_req/2, couch_doc_open/4, couch_doc_open/5]). -import(couch_httpd, [send_json/2,send_json/3,send_json/4,send_method_not_allowed/2, @@ -538,20 +538,27 @@ db_doc_req(Req, _Db, _DocId) -> % 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 -> - throw(Error) + Error when Throw -> + throw(Error); + _ -> + nil 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]} -> - throw(Else) + {ok, [Else]} when Throw -> + throw(Else); + {ok, _} -> + nil end end. |