Im calling a WCF service from jquery ajax. Sometimes the service throw some custom errors and when it does I need to get the message of that error. In the error function of my ajax call I have the following code:
error: function(data) {
alert("responseText: " + data.responseText);
}
And the responseText when the error is thrown looks something like:
responseText: {"ExceptionDetail":{"HelpLink":null,"InnerException":null,"Message":"Denied",......}}
I want to get the "Message" from "ExceptionDetail" but I'm not sure how to do it.
My WCF service looks like this, to test it I just throw an error:
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public string myFunction(string id)
{
throw new Exception("Denied");
}
How can I get the Message of the error?