mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-24 09:58:51 +00:00
Improved error handling
This commit is contained in:
parent
12ed35884f
commit
8764187273
@ -62,8 +62,19 @@ ComunicWeb.common.api.makeAPIrequest = function(apiURI, params, requireLoginToke
|
|||||||
ComunicWeb.common.network.setStatus(true);
|
ComunicWeb.common.network.setStatus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Prepare result
|
//Check if response is empty
|
||||||
var result = JSON.parse(apiXHR.responseText);
|
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);
|
||||||
|
|
||||||
//We check if we got any error
|
//We check if we got any error
|
||||||
if(result.error){
|
if(result.error){
|
||||||
|
Loading…
Reference in New Issue
Block a user