I have developed my application in ASP.net MVC5 using ServiceStack framework. In my app, on button click, I make ajax server call which returns data.
this.LoadData = function(){
$.ajax({
url: '@Url.Action("SearchCustomer", "Customer")',
cache: false,
type: 'GET',
contentType: 'application/json',
data: { 'IndexNo': this.IndexNo },
success: function (result) {
},
error: function (xhr, status, error) {
}
});
}
In some circumstances, my service layer throws exception (which I understand should get serialized into the ResponseStatus object of Response DTO). In the error function of above ajax call, I want to retrieve the custom exception message which my service layer throws. How I can achieve that? status and error above holds the serialized ResponseStatus information i.e. "Internal server error", error code 500 etc. What I want is custom error message thrown by my service layer.