Improved error handling

This commit is contained in:
Pierre 2017-06-25 16:30:38 +02:00
parent 12ed35884f
commit 8764187273

View File

@ -62,6 +62,17 @@ ComunicWeb.common.api.makeAPIrequest = function(apiURI, params, requireLoginToke
ComunicWeb.common.network.setStatus(true);
}
//Check if response is empty
if(apiXHR.responseText.length == ""){
//Auto-create a response for empty responses (to avoid Javascript errors and allow the script to continue to execute)
result = {
error : {
code: 0,
message: "Empty response",
},
};
}
else
//Prepare result
var result = JSON.parse(apiXHR.responseText);