I want to return a specific message on error of an ajax request.
[WebMethod]
public static AjaxReturnObject SubmitWager(string token, string track, string race, string amount, string pool, string runners)
{
try
{
var serviceReturn = Services.Account.SubmitWager("", track, race, pool, amount, runners);
return new AjaxReturnObject(serviceReturn.AccountToken, serviceReturn.Payload);
}
catch (CustomServiceException<string> e)
{
throw new Exception(e.Message);
}
}
Debugging says that it hits my catch when I need it to, but when I look at the xhr within my jquery ajax call it ALWAYS says "There was an error processing the request."
error: function (xhr, textStatus, errorThrown) {
log(xhr, textStatus, errorThrown);
}
How can I get my desired message to comeback to the ajax call under xhr.responseText?