aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-03-27 18:43:42 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-03-27 18:43:42 +0800
commitaa2a8cc4dff60c19e17383daf76370a8b6aa4c79 (patch)
treefda59e6bce6fc9d907ed8af2daf9d11d083e85b2 /utils
parent3dbe53182c12d6cf9f0deca1ea1a7af53dddfca2 (diff)
downloadSoopyV2-aa2a8cc4dff60c19e17383daf76370a8b6aa4c79.tar.gz
SoopyV2-aa2a8cc4dff60c19e17383daf76370a8b6aa4c79.tar.bz2
SoopyV2-aa2a8cc4dff60c19e17383daf76370a8b6aa4c79.zip
fix error parsing data stopping all futire network requests
Diffstat (limited to 'utils')
-rw-r--r--utils/networkUtils.js26
1 files changed, 19 insertions, 7 deletions
diff --git a/utils/networkUtils.js b/utils/networkUtils.js
index 51090b2..aaad6e2 100644
--- a/utils/networkUtils.js
+++ b/utils/networkUtils.js
@@ -92,14 +92,18 @@ if(!global.networkUtilsThingSoopy){
json: (callback)=>{
if(!callback){
if(loadedJSON === undefined){
- loadedJSON = JSON.parse(ret.text())
+ try{
+ loadedJSON = JSON.parse(ret.text())
+ }catch(e){}
}
return loadedJSON
}
ret.text(data=>{
+ try{
callback(JSON.parse(data))
+ }catch(e){}
})
},
responseCode: (callback)=>{
@@ -126,11 +130,15 @@ if(!global.networkUtilsThingSoopy){
new Thread(()=>{
while(running){
while(pendingRequests.length > 0){
- let req = pendingRequests.shift()
+ try{
+ let req = pendingRequests.shift()
- let data = getUrlContent(req.url, req.options)
+ let data = getUrlContent(req.url, req.options)
- pendingResolves.push([req.callback, data])
+ pendingResolves.push([req.callback, data])
+ }catch(e){
+ console.log(e, undefined, true)
+ }
}
Thread.sleep(100)
}
@@ -141,10 +149,14 @@ if(!global.networkUtilsThingSoopy){
})
register("tick", ()=>{
- while(pendingResolves.length > 0){
- let [callback, data] = pendingResolves.shift()
+ try{
+ while(pendingResolves.length > 0){
+ let [callback, data] = pendingResolves.shift()
- callback(data)
+ callback(data)
+ }
+ }catch(e){
+ console.log(e, undefined, true)
}
})