incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gregor Martynus <gre...@martynus.net>
Subject Re: update handler: how to return a status code?
Date Tue, 04 Oct 2011 09:43:35 GMT
Thanks Marcello, I've overseen that.

On Tue, Oct 4, 2011 at 5:56 AM, Marcello Nuccio
<marcello.nuccio@gmail.com>wrote:

> 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 <gregor@martynus.net>:
> > 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
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message