Gracefully handle design document updates with malformatted structure
Gracefully handle design document updates with malformatted structure

The existing code will break with a badmatch when a user attempts to
insert a design document with the following structure:

    {"_id": "_design/test",
     "views": "a string"}

This badmatch bubbles up to the user as an HTTP 500 with a nasty function
clause stacktrace[1].

With this patch, the user sees a clean HTTP 400 with a description of the
error[2].

[1]: https://gist.github.com/banjiewen/8dd395f152eef9269d77
[2]: https://gist.github.com/banjiewen/ae665af65171fb7c6572

BugzID: 23081

fkaempfer/couchdb,fkaempfer/couchdb,alanning/couchdb-couch,KlausTrainer/couchdb-couch,fkaempfer/couchdb,ngpestelos/couchdb-couch,smithsz/couchdb-couch,cloudant/couchdb-couch,ngpestelos/couchdb-couch,KlausTrainer/couchdb-couch,alanning/couchdb-couch,KlausTrainer/couchdb-couch,smithsz/couchdb-couch,fkaempfer/couchdb,apache/couchdb-couch,fkaempfer/couchdb,cloudant/couchdb-couch,apache/couchdb-couch,cloudant/couchdb-couch,apache/couchdb-couch,alanning/couchdb-couch,fkaempfer/couchdb,ngpestelos/couchdb-couch,smithsz/couchdb-couch