>From the [wiki][1]: Though you can set the headers, right now the status code for an update function response is hardcoded to be 200/201 unless an error occurs. See [this issue][2] in JIRA.
And the issue was fixed a few days ago. [1]: http://wiki.apache.org/couchdb/Document_Update_Handlers [2]: https://issues.apache.org/jira/browse/COUCHDB-648 Marcello 2011/10/3 Gregor Martynus <[email protected]>: > This is my update handler > > function (doc, req) { > var resp; > if (doc == null) { > doc = {}; > } > if (doc.email) { > resp = { > status: 403, > body: 'already signed up with ' + doc.email > }; > return [doc, resp]; > } else { > ... > } > } > > Instead of a response with an 403 error, I get a 500 with this content: > {"error":"external_response_error","reason":"Invalid data from external > server: {<<\"status\">>,403}"} > > The logs don't tell more neither. > > Is this a bug or is it simply not intended to work this way? > > – Gregor > > > > PS: Just figured out that it works like that: > throw(['error', 'forbidden','already signed up with ' + doc.email) > > I'd still appreciate an explanation >
