couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r729447 - in /couchdb/branches/form: share/www/script/couch_tests.js src/couchdb/couch_httpd_form.erl
Date Thu, 25 Dec 2008 21:54:33 GMT
Author: jchris
Date: Thu Dec 25 13:54:32 2008
New Revision: 729447

URL: http://svn.apache.org/viewvc?rev=729447&view=rev
Log:
better error handling for missing docs and design docs

Modified:
    couchdb/branches/form/share/www/script/couch_tests.js
    couchdb/branches/form/src/couchdb/couch_httpd_form.erl

Modified: couchdb/branches/form/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/branches/form/share/www/script/couch_tests.js?rev=729447&r1=729446&r2=729447&view=diff
==============================================================================
--- couchdb/branches/form/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/branches/form/share/www/script/couch_tests.js [utf-8] Thu Dec 25 13:54:32 2008
@@ -1836,7 +1836,7 @@
     T(xhr.status == 200)
   },
 
-   templates: function(debug) {
+   forms: function(debug) {
      var db = new CouchDB("test_suite_db");
      db.deleteDb();
      db.createDb();
@@ -1939,6 +1939,22 @@
      xhr = CouchDB.request("GET", "/test_suite_db/_form/template/just-name/"+docid);
      T(xhr.responseText == "Just Rusty");
      
+     // form with missing doc
+     xhr = CouchDB.request("GET", "/test_suite_db/_form/template/just-name/missingdoc");
+     T(xhr.status == 404);
+     var resp = JSON.parse(xhr.responseText);
+     T(resp.error == "not_found");
+     T(resp.reason == "missing");
+     
+     // missing design doc
+     xhr = CouchDB.request("GET", "/test_suite_db/_form/missingdoc/just-name/"+docid);
+     T(xhr.status == 404);
+     var resp = JSON.parse(xhr.responseText);
+     console.log(resp)
+     T(resp.error == "not_found");
+     T(resp.reason == "missing_design_doc");
+     
+     
      // query parameters
      xhr = CouchDB.request("GET", "/test_suite_db/_form/template/req-info/"+docid+"?foo=bar",
{
        headers: {

Modified: couchdb/branches/form/src/couchdb/couch_httpd_form.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/form/src/couchdb/couch_httpd_form.erl?rev=729447&r1=729446&r2=729447&view=diff
==============================================================================
--- couchdb/branches/form/src/couchdb/couch_httpd_form.erl (original)
+++ couchdb/branches/form/src/couchdb/couch_httpd_form.erl Thu Dec 25 13:54:32 2008
@@ -26,7 +26,7 @@
     DesignId = <<"_design/", DesignName/binary>>,
     % Anyway we can dry up this error handling?
     case (catch couch_httpd_db:couch_doc_open(Db, DesignId, [], [])) of
-    {{not_found, missing}, _} ->
+    {not_found, missing} ->
         throw({not_found, missing_design_doc});
     {not_found, deleted} ->
         throw({not_found, deleted_design_doc});
@@ -40,7 +40,7 @@
                 throw({not_found, missing_form});
             FormSrc ->
                 case (catch couch_httpd_db:couch_doc_open(Db, Docid, [], [])) of
-                {{not_found, missing}, _} ->
+                {not_found, missing} ->
                     throw({not_found, missing});
                 {not_found, deleted} ->
                     throw({not_found, deleted});



Mime
View raw message