Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to find the best way to pass exceptions or messages from my Odata Service back to an Odata web forms client.

On the service, when I call this controller:

public async Task<ihttpactionresult> Post(Products product)
{

var message = "Product with id = not found";
throw new HttpResponseException(
Request.CreateErrorResponse(HttpStatusCode.NotImplemented, message));
}

It throws a HttpResponse exeption with the HttpError in the content as expected.

However, on the client side, the exception arrives as either a DataServiceRequestException or DataServiceQueryException and the inner exception message is formatted as follows:


{
"odata.error":{
"code":"","message":{
"lang":"en-US","value":"Product with id = not found"
}
}
}

So, how do I easily extract the message from the JSON?

Is this the best way to do it?

Should I just return a response code and put the message in the headers?

Does anyone have an example of a webforms client with error management that they can point me to please?

I have spent hours on this and don't know what to do.

Thanks
Jeff
Posted

1 solution

I'm still struggling with this. Does anyone have a hint please?

Thanks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900