You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/03/20 14:09:01 UTC

couchdb commit: updated refs/heads/Query-Options-UI to f0f3bd6

Repository: couchdb
Updated Branches:
  refs/heads/Query-Options-UI c567d85f1 -> f0f3bd6fb


Fix parseJSON to return object with error


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

Branch: refs/heads/Query-Options-UI
Commit: f0f3bd6fb4f474b7ed828b08e2e16db359516c44
Parents: c567d85
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Mar 20 15:08:58 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Mar 20 15:08:58 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/documents/views.js | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f0f3bd6f/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index ee6b253..579c711 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1135,15 +1135,21 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
 
     parseJSON: function (value) {
       try {
-        return JSON.parse(value);
+        return {
+         value: JSON.parse(value),
+         error: null
+        };
       } catch(e) {
-        return false;
+        return {
+          error: e,
+          value: null
+        };
       }
     },
 
     validateKeys:  function(param){
       var parsedValue = this.parseJSON(param.value);
-      if (!parsedValue || !_.isArray(parsedValue)) {
+      if (parsedValue.error || !_.isArray(parsedValue.value)) {
         this.$('.js-keys-error').empty();
         FauxtonAPI.addNotification({
           type: "error",
@@ -1174,7 +1180,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
       var keyParams = ["keys","startkey","endkey"];
       var errorParams = _.filter(params, function(param) {
         if (_.contains(keyParams, param.name)) {
-          return !!!this.parseJSON(param.value);
+          return !!this.parseJSON(param.value).error;
         } else {
           return false;
         }