I have created a WCF data service with a service operation.
I want to generate a kind of Business exception. I try to generate WebFaultException
but I don't see how to catch this error at the client side when this error is throwing by a service operation.
Here is my service operation to simulate an exception:
[WebGet]
public void GenerateException()
{
throw new DataServiceException( 403, "Custom Message" );
}
Here is my client:
WebClient wc = new WebClient();
wc.DownloadString(
new Uri(
"http://localhost:27820/WcfDataService1.svc/GenerateException"
)
);
DownloadString
is throwing an exception, but it's only Internal Server Error
, I can't see my Custom Message
.
Any Idea ?
Many Thanks.