You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2008/12/30 11:45:20 UTC
[Couchdb Wiki] Update of "Error messages" by JanLehnardt
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);
+ }
+ }
+ }}}
+