couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [09/18] git commit: Report database_not_found errors to clients
Date Fri, 17 Jan 2014 21:41:35 GMT
Report database_not_found errors to clients

Bit of a regression on trying to load views from dbs that didn't exist
created a bad match when we returned an error instead of {ok, DDoc}.
This just tracks database_not_found and throws errors instead of
returning them.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/commit/304b46f0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/tree/304b46f0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/diff/304b46f0

Branch: refs/heads/import
Commit: 304b46f002ff8a42dd9896299e2d75d292ffce73
Parents: 3c7c53d
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Thu Jan 24 17:31:41 2013 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Thu Jan 24 17:31:41 2013 -0600

----------------------------------------------------------------------
 src/ddoc_cache.erl        |  7 ++++++-
 src/ddoc_cache_opener.erl | 11 +++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/blob/304b46f0/src/ddoc_cache.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache.erl b/src/ddoc_cache.erl
index 332b08b..e4e16bd 100644
--- a/src/ddoc_cache.erl
+++ b/src/ddoc_cache.erl
@@ -37,7 +37,12 @@ open(Key) ->
         {ok, _} = Resp ->
             Resp;
         _ ->
-            gen_server:call(?OPENER, {open, Key}, infinity)
+            case gen_server:call(?OPENER, {open, Key}, infinity) of
+                {ok, _} = Resp ->
+                    Resp;
+                Else ->
+                    throw(Else)
+            end
     end.
 
 

http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/blob/304b46f0/src/ddoc_cache_opener.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache_opener.erl b/src/ddoc_cache_opener.erl
index 541fabd..5a899b0 100644
--- a/src/ddoc_cache_opener.erl
+++ b/src/ddoc_cache_opener.erl
@@ -168,12 +168,15 @@ open_ddoc({DbName, validation_funs}=Key) ->
     ok = ets_lru:insert(ddoc_cache_lru, {DbName, validation_funs}, Funs),
     exit({ddoc_ok, Key, Funs});
 open_ddoc({DbName, DDocId}=Key) ->
-    case fabric:open_doc(DbName, DDocId, []) of
+    try fabric:open_doc(DbName, DDocId, []) of
         {ok, Doc} ->
             ok = ets_lru:insert(ddoc_cache_lru, {DbName, DDocId}, Doc),
-            exit({ddoc_ok, Key, Doc});
-        Else ->
-            exit({ddoc_error, Key, Else})
+            exit({ddoc_ok, Key, Doc})
+    catch
+        error:database_not_found ->
+            exit({ddoc_error, Key, database_not_found});
+        _Type:Reason ->
+            exit({ddoc_error, Key, Reason})
     end.
 
 


Mime
View raw message