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