I am using WCF REST Starter Kit Preview 2 and i have problem with catching exceptions in client side. I am using
HttpClient.EnsureStatusIsSuccessful()
method to catch my
new WebProtocolException(HttpStatusCode.InternalServerError, "Hello World!");
in the client. And since when an InternalServerError happens an ArgumentOutOfRangeException is thrown, I catch it in client side, but it didn't have any information (like "Hello World!") beside that there is an error. I can see that in the content of HttpResponseMessage there is information that I see when I use a web browser to access the service method.
I am wondering what is the correct way to throw the WebProtocolException and catching it? I have several business exceptions but most of them are just return some user-friendly information to the user. and maybe some error-code but http status codes are enough I guess.
I just want to throw and catch the exceptions in a clean way.
I am using the WebServiceHost2Factory.