Here's my service code. I throw an error just like all the best-practice articles suggest - in a form of WebFaultException.
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class API
{
[OperationContract]
[WebGet()]
public int MyMethod()
{
throw new WebFaultException<string>("TESTERROR", HttpStatusCode.BadRequest);
}
}
Now when a send a request to http://localhost:1389/API.svc/MyMethod all I get is this JSON object:
{"ExceptionDetail":null,"ExceptionType":null,"Message":"The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.","StackTrace":null}
I tried enabling includeExceptionDetailInFaults in my web.config, the message does change a little, but still I don't see my "TESTERROR" anywhere!