couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Error messages" by JanLehnardt
Date Tue, 30 Dec 2008 10:45:20 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by JanLehnardt:
http://wiki.apache.org/couchdb/Error_messages

The comment on the change is:
JS error explanation.

------------------------------------------------------------------------------
  
  This is related to an update made in erlang (http://www.nabble.com/OS-X-fixes-(HiPE,-ddll-unload)-td19411880.html)
Upgrading to version R12B-5 or higher should fix things.
  
+ == function raised exception (Cannot encode 'undefined' value as JSON) ==
+ 
+ === Problem ===
+ 
+ A view index fails to build, CouchDB Logs this error message:
+ 
+ {{{
+ function raised exception (Cannot encode 'undefined' value as JSON)
+ }}}
+ 
+ === Solution ===
+ 
+ The JavaScript code you are using for the map or reduce function is using an object member
that is not defined. Consider this document
+ 
+ {{{
+ {
+   "_id":"XYZ123",
+   "_rev":"1BB2BB",
+   "field":"value"
+ }
+ }}}
+ 
+ And this map function:
+ 
+ {{{
+ function(doc) {
+   emit(doc.name, doc.address);
+ }
+ }}}
+ 
+ Use guarding to make sure to only access members when they exist in the passed-in document:
+ 
+ {{{
+ function(doc) {
+   if(doc.name && doc.address) {
+       emit(doc.name, doc.address);
+   }
+ }
+ }}}
+ 

Mime
View raw message