2
0
Fork 0

added error on parse + obj

This commit is contained in:
Willem 2016-03-14 00:42:10 +01:00
parent 7a2f9bf7ad
commit 43d9f243d8
2 changed files with 17 additions and 1 deletions

View file

@ -221,6 +221,7 @@ Add unit tests for any new or changed functionality. Lint and test your code.
* refined css so question/loader/error are equal.
* Added response header check support.
* Added json accept header on assets resources list.
* Added cb errors on assets resources json parse + result obj.
### 0.1.1
* Moved websql delete timeout to cleanServerlUrl for faster boot.

View file

@ -761,7 +761,22 @@
}
return;
}
var resources = JSON.parse(httpRequest.responseText).data.resources;
var resources = null;
try {
var responseObject = JSON.parse(httpRequest.responseText);
if (responseObject.data === undefined) {
return cb('No data in json');
}
if (responseObject.data.resources === undefined) {
return cb('No resources in json');
}
if (responseObject.data.resources.length === 0) {
return cb('Empty resources in json');
}
resources = responseObject.data.resources;
} catch (parseError) {
return cb(parseError);
}
utilDebug('startLoader resources '+resources.length);
var progressBar = createLoaderBar(resources);