couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <>
Subject Re: _show without docid returns 500 instead of 404
Date Tue, 01 Dec 2009 16:44:40 GMT
On Tue, Dec 1, 2009 at 3:51 AM, Markus Jelsma - Buyways B.V.
<> wrote:
> Hello Patrick,
> I agree that operating on a null as if it were a proper document should
> raise an error.  But then i believe the book should not write "If the
> document with id 72d43a93eb74b5f2 does not exist, the request will
> result in an HTTP 404 Not Found error response." in the paragraph
> previous to the one you mention, is it not?

I think in this case the book is wrong (or maybe it is right and the
code is wrong). In the case of a missing doc the code currently forces
you to raise the 404 error from your show function.

I think this was done so that you have the option to render your own
404 error message, instead of being stuck with CouchDB's JSON message.

The arguments for the CouchDB handling 404 for you:

It's simpler to program because CouchDB handles some major error
handling for you (and properly)
It's more efficient b/c your JS function is not called in the case of
a missing docid.

The arguments for the current system (handle your own errors) pretty
much boil down to some increased flexibility. The flexibility of 404
messages might be better handled outside of show functions anyway.

I am leaning toward the description the book gives (which would mean a
code change). If you convince me it should be changed, I'll change it.
Is anyone relying on the ability of show functions to render their own

The change would be simple, just remove a catch clause on
couch_httpd_show.erl line 81.


Chris Anderson

View raw message