Displaying Server Side Errors

Displaying Server Side Errors

fastbikefastbike Posts: 14Questions: 0Answers: 0
edited March 2010 in General
What is the best way to propogate a server side error message and display it in the client DataTable ?

I am currently using a server side try/catch block, and adding an extra field to the json object returned by the server.
[code]
{"sError":"The error message from the server","sEcho":1,"iTotalRecords":0,"iTotalDisplayRecords":0,"sColumns":"ReferralID,ReferralType,ReferralDate,Facility,Referrer,NHI,Patient,ReviewStatus","aaData":[]}
[/code]

I then specify a function for "fnServerData": getServerData which looks like
[code]
function getServerData( sSource, aoData, fnCallback ) {
$.getJSON( sSource, aoData, function (json) {
if (json.sError != undefined)
{
alert(json.sError);
}
fnCallback(json)
});
}
[/code]

Is this the best way to handle this or is there a built in method I can use ?

David
This discussion has been closed.