Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
FrenchYeti committed Feb 23, 2021
1 parent f5f29e9 commit dbba59a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
12 changes: 4 additions & 8 deletions src/DexcaliburProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,20 +415,16 @@ class DexcaliburProject
break;
default:
if(((pName instanceof Platform) === false) && (typeof pName == 'string' )){
//if(this.device instanceof Device){
// this.platform = this.device.getPlatform(pName);
//}else{
this.platform = pm.getPlatform(pName); //getFromAndroidApiVersion(this.application.getMaxApiVersion());
//}
this.platform = pm.getPlatform(pName);
}else{
this.platform = pName;
}
this.platform = pName;
}
break;
}

// check if platform is installed
if(this.platform == null){
throw new Error("[PROJECT] synchronizePlatform : unkow platform. Aborted")
throw new Error("[PROJECT] synchronizePlatform : unknow platform. Aborted")
}

// install platform
Expand Down
2 changes: 2 additions & 0 deletions src/PlatformManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class PlatformManager
return this.remote[pName];
}

console.log("[ERROR] Platform Manager : "+pName+" is not a valid platform");

// throw exception
return null;
}
Expand Down
17 changes: 12 additions & 5 deletions src/WebServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,24 +395,31 @@ class WebServer {
path = device.pullTemp( req.body['path'] );
break;
case 'download':
if(PLATFORM_MODE)
platform = PlatformManager.getInstance().getPlatform( req.body['platform']);
path = await Downloader.downloadTemp(req.body['url'], { mode:0o666, encoding:'binary', force:true });
break;
case 'upload':
platform = PlatformManager.getInstance().getPlatform( req.body['platform']);
path = $.uploader.getPathOf(req.body['uploadid']);
break;
case 'fromfs':
platform = PlatformManager.getInstance().getPlatform( req.body['platform']);
path = req.body['path'];
break;
}


if(platform==null){
if(PLATFORM_MODE.indexOf(req.body['platform'])==-1){
platform = PlatformManager.getInstance().getPlatform( req.body['platform']);
if(platform==null){
res.status(200).send(JSON.stringify({ success:false, code:6, msg:"This platform is not installed."}));
return;
}
}else{
platform = req.body['platform'];
}
}


// chcek if file exists an it is not empty
// check if file exists an it is not empty
if( (!fs.existsSync(path)) || (false)){
res.status(200).send(JSON.stringify({ success:false, code:5, msg:"APK file not found "}));
return;
Expand Down

0 comments on commit dbba59a

Please sign in to comment.