Gotcha: DocCtx#addError vs. CRUDOperationContext#addError

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Gotcha: DocCtx#addError vs. CRUDOperationContext#addError

dcrissman
In a CRUDController that I am working on I was setting errors on the DocCtx [E1],  but they were not being received by the client. As I dug around some more, turns out that I should have been setting the error on the CRUDOperationContext [E2].

Under what circumstance would you add an error the the DocCtx? I see examples in the Mongo code base, but I question if the errors are actually be sent back to the client.

[E1]
DocCtx erroredDoc = new DocCtx(new JsonDoc(null));
erroredDoc.addError(Error.get(...));
ctx.addDocument(erroredDoc);

[E2]
ctx.addError(Error.get(...));
Reply | Threaded
Open this post in threaded view
|

Re: Gotcha: DocCtx#addError vs. CRUDOperationContext#addError

bserdar
Error you add to DocCtx *should* be returned to the client. They will
be returned in dataErrors array, not in errors array. Look at
CRUDOperationContext.getDataErrors implementation, and mediator calls
that to build the response.

Which call is this?

On Tue, Jan 27, 2015 at 8:45 AM, dcrissman [via lightblue-dev]
<[hidden email]> wrote:

> In a CRUDController that I am working on I was setting errors on the DocCtx
> [E1],  but they were not being received by the client. As I dug around some
> more, turns out that I should have been setting the error on the
> CRUDOperationContext [E2].
>
> Under what circumstance would you add an error the the DocCtx? I see
> examples in the Mongo code base, but I question if the errors are actually
> be sent back to the client.
>
> [E1]
> DocCtx erroredDoc = new DocCtx(new JsonDoc(null));
> erroredDoc.addError(Error.get(...));
> ctx.addDocument(erroredDoc);
>
> [E2]
> ctx.addError(Error.get(...));
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://dev.forum.lightblue.io/Gotcha-DocCtx-addError-vs-CRUDOperationContext-addError-tp331.html
> To start a new topic under lightblue-dev, email
> [hidden email]
> To unsubscribe from lightblue-dev, click here.
> NAML
Reply | Threaded
Open this post in threaded view
|

Re: Gotcha: DocCtx#addError vs. CRUDOperationContext#addError

bserdar
In reply to this post by dcrissman
I checked the code, and find() implementation does not set the
dataErrors array. Fix that instead in core.

On Tue, Jan 27, 2015 at 9:53 AM, Burak Serdar <[hidden email]> wrote:

> Error you add to DocCtx *should* be returned to the client. They will
> be returned in dataErrors array, not in errors array. Look at
> CRUDOperationContext.getDataErrors implementation, and mediator calls
> that to build the response.
>
> Which call is this?
>
> On Tue, Jan 27, 2015 at 8:45 AM, dcrissman [via lightblue-dev]
> <[hidden email]> wrote:
>> In a CRUDController that I am working on I was setting errors on the DocCtx
>> [E1],  but they were not being received by the client. As I dug around some
>> more, turns out that I should have been setting the error on the
>> CRUDOperationContext [E2].
>>
>> Under what circumstance would you add an error the the DocCtx? I see
>> examples in the Mongo code base, but I question if the errors are actually
>> be sent back to the client.
>>
>> [E1]
>> DocCtx erroredDoc = new DocCtx(new JsonDoc(null));
>> erroredDoc.addError(Error.get(...));
>> ctx.addDocument(erroredDoc);
>>
>> [E2]
>> ctx.addError(Error.get(...));
>>
>> ________________________________
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://dev.forum.lightblue.io/Gotcha-DocCtx-addError-vs-CRUDOperationContext-addError-tp331.html
>> To start a new topic under lightblue-dev, email
>> [hidden email]
>> To unsubscribe from lightblue-dev, click here.
>> NAML
Reply | Threaded
Open this post in threaded view
|

Re: Gotcha: DocCtx#addError vs. CRUDOperationContext#addError

dcrissman
In reply to this post by bserdar
It is indeed for a Find
Reply | Threaded
Open this post in threaded view
|

Re: Gotcha: DocCtx#addError vs. CRUDOperationContext#addError

dcrissman
In reply to this post by bserdar